13 Commands to Find Architecture of Linux OS and CPU (32 & 64) Bit

Assume that administrator is in need to alter the existing system configuration or simply he wants to install a new software or hardware device before performing his needful task, he has to know the details of the system to make sure that the new software/hardware will work fine with the system environment. To get the information about operating system like kernel version, kernel release info and processor type info, you can use some commands. Below examples give more details about the command.

About CPU and OS architecture

You should take in mind that you may have a 64 bit CPU while you install a 32 bit kernel. I.e. If your CPU is 64 bits it doesn't mean that your OS is 64 bits, it depends on what you've installed.

Commands to find CPU architecture

There are some command which helps you to know if your CPU is 32 bits or 64 bits

1. Print system information

It is possible to use uname command to have some Linux system architecture information but you can have the processor type with uname -p command

$ uname -p

If the command doesn't work, you can use uname -a command which gives more information

2. Print hardware name

arch command will display the machine architecture.

# arch

3. Display cpu information

You can display CPU architecture information with lscpu command

$ lscpu
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 4
On-line CPU(s) list: 0-3

The result has been truncated. You can see that the output shows the cpu compatibility mode (32 and 64 bits)

4. List hardware description

You can us lshw -c command to filter CPU information on the hardware description which will appear

# lshw -c cpu
 description: CPU
 product: Intel(R) Core(TM) i5-3230M CPU @ 2.60GHz
 vendor: Intel Corp.
 physical id: 33
 bus info: [email protected]
 version: Intel(R) Core(TM) i5-3230M CPU @ 2.60GHz
 serial: To Be Filled By O.E.M.
 slot: U3E1
 size: 2973MHz
 capacity: 3200MHz
 width: 64 bits

You can the last line width: 64 bits which indicate the type of processor. This command for the moment doesn't work on Red Hat based system but only Debian based system.

5. Display CPU info file

You can list /proc/cpuinfo content file to check whether you processor is 32 bits or 64 bits. If you want to see if your processor is 64-bit then look for lm (means Long Mode) in the flags listed in /proc/cpuinfo.

# grep -o -w 'lm' /proc/cpuinfo | sort -u

Command to check Linux OS type (32 or 64 bits)

You should notice that having an operating system on 64 bits means that you CPU is 64 bits too so these commands below can also help you to determine your CPU architecture. But keep in mind that you can have a 32 bits OS but 64 bits CPU so it is better to check this individually.

6. Get configuration value

You can use the getconf command to know whether the kernel is of 32 bit or 64 bit.

# getconf LONG_BIT

For 32 bits system, you will have 32 instead of 64 

7. Print system information

uname command has some options which give a special information and we can have some more information as the OS type with -a option of the command

# uname -a
Linux centos-01 3.10.0-514.16.1.el7.x86_64 #1 SMP Wed Apr 12 15:04:24 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

In above output x86_64 GNU/Linux indicates that you've a 64bit Linux kernel running. If you see i386/i486/i586/i686 it is a 32 bit kernel. The command tells you if the Linux kernel is 64 bit or 32 bit. If the output includes x86_64, then the kernel is 64 bits, this means the OS must be 64 bit. If there is no X86_64, there should be something like 686 or 486 to say what 32 bit CPU the kernel was built for.

8. Print architecture of package

When you have a 64 bits OS installed, it means that your CPU is 64 bits too and the packages installed will correspond to the same architecture. So we can see the installed package architecture on our system to determine our OS type

$ dpkg --print-architecture 

You can understand that the command can be only used on Debian based systems.

9. Show installed libraries

The libraries installed on an OS help to determinate the type of this one. When you have a 64 bits OS, you will have 64 bits libraries installed too.

# ls -la / | grep lib
lrwxrwxrwx. 1 root root 7 Feb 21 13:38 lib -> usr/lib
lrwxrwxrwx. 1 root root 9 Feb 21 13:38 lib64 -> usr/lib64

10. Print package information

You can use yum info to have some information about available packages. It will also print architecture of OS which is compatible with the package

# yum info nginx | grep -i arch
Arch : x86_64

Because our OS is 64 bits, the package is compatible with 64 bits too

11. Show host type

It is possible to have the version of your operating system by displaying the OS type

$ echo $HOSTTYPE

12. By using file type

file command determines file type. The result on the output contains your system architecture

# file /lib/systemd/systemd
/lib/systemd/systemd: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=8019aadd1f0962539e2f746b044873956ce2e32c, stripped

You can see ELF 64-bit, X86-64

For non-systemd OS, you can use

# file /sbin/init

13. Show machine type

It is possible to display machine type to have your OS version

# echo $MACHTYPE

You can see that the OS version


It is important to know the version of our CPU and OS for some packages operations. It helps to ensure the compatibility mode on our system and to make sure to use the max performance of resources available. There are some commands which help to check this. Don't forget that a 32 bits OS can be installed on a 64 bits CPU so it is important to check each version to know exactly what to do.

Bobbin Zachariah 10:22 am

About Bobbin Zachariah

Founder of LinOxide, passionate lover of Linux and technology writer. Started his career in Linux / Opensource from 2000. Love traveling, blogging and listening music. Reach Bobbin Zachariah about me page and google plus page.

Author Archive Page

Have anything to say?

Your email address will not be published. Required fields are marked *

All comments are subject to moderation.