To check for a 64-bit capable CPU on a x86 system running on Linux, we can make use the /proc/cpuinfo
file. Note that this will not determine if the OS is 64-bit or not. It will only determine if the CPU is capable of running a 64-bit OS. To check if the Linux OS is running 32-bit or 64-bit, you can refer to this article instead.
To check for 64-bit capability, we will need to check for the presence of the lm
(Long Mode) flag. In the x86-64 computer architecture, long mode is the mode where a 64-bit OS can access 64-bit instructions and registers.
If 64-bit is supported, you will get an output of 0 from the following command.
1 2 |
$ cat /proc/cpuinfo | grep -i flags | grep -q lm ; echo $? 0 |
If lm
flag is not found under the CPU flags, then the CPU will not support 64-bit mode and you will get an output of 1 from the following command.
1 2 |
$ cat /proc/cpuinfo | grep -i flags | grep -q lm ; echo $? 1 |
Note that you can still run a 32-bit OS on a 64-bit capable CPU. But a 64-bit OS can only be run on a CPU that has 64-bit support.