Linux: How to Check If Linux Kernel is 32 or 64 Bit

When writing configure scripts, it’s good to check if we are running on a 32-bit or 64-bit kernel or OS on a x86 system. There are a few ways to determine the machine architecture of a Linux system.

The first method is to use the uname command. On a 32-bit kernel, you will get something like iX86, or more specifically one of these: i386, i486, i586 or i686.

On a 64-bit system, you will get x86_64.

Another way is to use the getconf utility and check the size of long int variable. The output is self-explanatory – 32 for 32-bit and 64 for 64-bit OS.

The third method is to use lscpu command and grep the Architecture line.

The forth and final method is to use the arch command.

Do not check /proc/cpuinfo for 64-bit OS support. The /proc/cpuinfo file will only give you the CPU capabilities, not the capabilities of the OS. A CPU may support running in 64-bit mode, but the underlying OS could be running on 32-bit. To check the CPU for 64-bit support, you can refer to this article.

ibrahim = { interested_in(unix, linux, android, open_source, reverse_engineering); coding(c, shell, php, python, java, javascript, nodejs, react); plays_on(xbox, ps4); linux_desktop_user(true); }