- How to determine whether a given Linux is 32 bit or 64 bit?
- 21 Answers 21
- 5 Command Line Ways to Find Out Linux System is 32-bit or 64-bit
- 1. uname Command
- 2. dpkg Command
- 3. getconf Command
- 4. arch Command
- 5. file Command
- Conclusion
- Related Posts
- 11 thoughts on “5 Command Line Ways to Find Out Linux System is 32-bit or 64-bit”
- how to know if cpu is running in 64 bit in linux? [duplicate]
- 2 Answers 2
- Using uname:
- Using lscpu:
- Other solutions:
How to determine whether a given Linux is 32 bit or 64 bit?
How can I know from this that the given OS is 32 or 64 bit? This is useful when writing configure scripts, for example: what architecture am I building for?
21 Answers 21
Try uname -m . Which is short of uname —machine and it outputs:
x86_64 ==> 64-bit kernel i686 ==> 32-bit kernel
Otherwise, not for the Linux kernel, but for the CPU, you type:
Under «flags» parameter, you will see various values: see «What do the flags in /proc/cpuinfo mean?» Among them, one is named lm : Long Mode (x86-64: amd64, also known as Intel 64, i.e. 64-bit capable)
Or using lshw (as mentioned below by Rolf of Saxony), without sudo (just for grepping the cpu width):
lshw -class cpu|grep "^ width"|uniq|awk ''
Note: you can have a 64-bit CPU with a 32-bit kernel installed.
(as ysdx mentions in his/her own answer, «Nowadays, a system can be multiarch so it does not make sense anyway. You might want to find the default target of the compiler»)
grep flags /proc/cpuinfo only tells you wether the CPU is 64bit. As I understand the question it was about the OS. uname -m only tells me «i686».
I have a 32 bit kernel on 64 bit hardware and get «x86_64» from ‘uname -m’ (on Debian). The man page for uname says that -m shows the machine hardware name, so that seems correct.
If I have a 32-bit kernel running on a 64-bit machine/ processor, what would uname -i , uname -p and uname -m show?
@JavierNovoaC. tm (Thermal Monitor) indicates Automatic clock control. It has nothing to do with distinguishing a 32-bit processor. In fact, lm (long mode) is present if and only if you have a 64-bit CPU. So that’s why you should only rely on lm. otherwise the answer given by Thomas Watnedal is the best. This answer is just wrong and has misled many people plz moderators do something about it.
If you were running a 64 bit platform you would see x86_64 or something very similar in the output from uname -a
To get your specific machine hardware name run
which returns either 32 or 64
That means the CPU is 64-bit, but you’ve only installed a 32-bit operating system upon it, even though you could have used a 64-bit one.
Steve Kemp is right, so be careful (Mac OS X 10.5 on 2009 MacBooks comes to mind, where the OS is 32-bit but its capable of running 64-bit apps)
The uname -m is not useful for the QP’s configure as it can give the wrong result. The getconf LONG_BIT get the default bit size of the C library which may not be the correct size for a specified, by CC , compiler.
getconf LONG_BIT may provide 32 ig it has been built as a 32 bit application (typically 64 bit kernel running a 32 bit userland).
lscpu will list out these among other information regarding your CPU:
Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit .
Outputs the physical capabilities of the CPU, useful, but not reliable for the current userspace of the current OS.
Totaly wrong. The question is what OS is running. 42 upvotes? I would spend a down vote but it would drown.
Another useful command for easy determination is as below:
I guess it all depends on what the questioner means by «64-bit» — it used to mean the natural size of integers, but it’s now often used to mean the addressing size instead.
but is twice as fast to type
This returns the process types that the kernel can support. It is possible and even reasonable to run a 32 bit userspace on a 64bit kernel.
I was wondering about this specifically for building software in Debian (the installed Debian system can be a 32-bit version with a 32 bit kernel, libraries, etc., or it can be a 64-bit version with stuff compiled for the 64-bit rather than 32-bit compatibility mode).
Debian packages themselves need to know what architecture they are for (of course) when they actually create the package with all of its metadata, including platform architecture, so there is a packaging tool that outputs it for other packaging tools and scripts to use, called dpkg-architecture. It includes both what it’s configured to build for, as well as the current host. (Normally these are the same though.) Example output on a 64-bit machine:
DEB_BUILD_ARCH=amd64 DEB_BUILD_ARCH_OS=linux DEB_BUILD_ARCH_CPU=amd64 DEB_BUILD_GNU_CPU=x86_64 DEB_BUILD_GNU_SYSTEM=linux-gnu DEB_BUILD_GNU_TYPE=x86_64-linux-gnu DEB_HOST_ARCH=amd64 DEB_HOST_ARCH_OS=linux DEB_HOST_ARCH_CPU=amd64 DEB_HOST_GNU_CPU=x86_64 DEB_HOST_GNU_SYSTEM=linux-gnu DEB_HOST_GNU_TYPE=x86_64-linux-gnu
You can print just one of those variables or do a test against their values with command line options to dpkg-architecture.
I have no idea how dpkg-architecture deduces the architecture, but you could look at its documentation or source code (dpkg-architecture and much of the dpkg system in general are Perl).
5 Command Line Ways to Find Out Linux System is 32-bit or 64-bit
This tutorial describes how to find out whether your Linux system’s OS is 32-bit or 64-bit. This will be helpful if you wanted to download or install an application in your Linux system. As we all know, we can’t install 64-bit applications into a 32-bit OS type. That’s why knowing your Linux system’s OS type is important.
Here are the five easy and simple methods to verify your Linux system’s OS type. It doesn’t matter whether you’re using a GUI or CLI type systems, the following commands will work on almost all Linux operating systems such as RHEL, CentOS, Fedora, Scientific Linux, Debian, Ubuntu, Linux Mint, openSUSE etc.
1. uname Command
uname -a command will display your Linux system’s OS type. This is the universal command and it will work on almost all Linux/Unix operating systems.
To find out the system’s OS type, run:
$ uname -a Linux tecmint.com 3.13.0-37-generic #64-Ubuntu SMP Mon Sep 22 21:28:38 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
2. dpkg Command
dpkg command will also display whether your Debian/Ubuntu operating system is 32-bit or 64-bit. This command will work only on Debian and Ubuntu based distributions and it’s derivatives.
Open your Terminal, and run:
$ dpkg --print-architecture
If your OS is 64-bit, you’ll get the following output:
If your OS is 32-bit, then the output will be:
3. getconf Command
getconf command will also display the system configuration variables. Now, let me show you how to find out the Linux system arch using getconf command.
$ getconf LONG_BIT 64
For more details refer the man pages.
4. arch Command
arch command will display your OS type. This command is similar to uname -m command. If its output is x86_64 then it’s 64-bit OS. If the output is i686 or i386, then it’s 32-bit OS.
5. file Command
file command with with a special argument /sbin/init will display the OS type.
$ file /sbin/init /sbin/init: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=7a4c688d009fc1f06ffc692f5f42ab09e68582b2, stripped
Conclusion
You now know the ways to find out your Linux operating system’s type. Of course, there are few other ways to find out the OS type, but these are the often and pragmatic methods so far. If you know any other commands or methods to display the OS type, feel free to let us know in the comments section below.
A Linux Consultant, living in India. He loves very much to write about Linux, Open Source, Computers and Internet. Apart from that, He’d like to review Internet tools and web services.
Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.
Related Posts
11 thoughts on “5 Command Line Ways to Find Out Linux System is 32-bit or 64-bit”
I’d just like to interject for a moment. What you’re referring to as Linux, is in fact, GNU/Linux, or as I’ve recently taken to calling it, GNU plus Linux. Linux is not an operating system unto itself, but rather another free component of a fully functioning GNU system made useful by the GNU corelibs, shell utilities and vital system components comprising a full OS as defined by POSIX. Many computer users run a modified version of the GNU system every day, without realizing it. Through a peculiar turn of events, the version of GNU which is widely used today is often called “Linux”, and many of its users are not aware that it is basically the GNU system, developed by the GNU Project. There really is a Linux, and these people are using it, but it is just a part of the system they use. Linux is the kernel: the program in the system that allocates the machine’s resources to the other programs that you run. The kernel is an essential part of an operating system, but useless by itself; it can only function in the context of a complete operating system. Linux is normally used in combination with the GNU operating system: the whole system is basically GNU with Linux added, or GNU/Linux. All the so-called “Linux” distributions are really distributions of GNU/Linux. Reply
Great post! You can also check using a environment variable: echo $HOSTTYPE Result: i386 -> 32 bits
x86_64 -> 64 bits Reply
how to know if cpu is running in 64 bit in linux? [duplicate]
I’m looking for a way to know if the cpu of my linux system is running in 64 bit mode. I’ve got to programm it for the university. My idea was to create something like an function that provides me that information. I’m not sure how should I start. Can somebody give me an idea?. My university give me a code, but I’m not able to check the length of the parameter that the main is sending to the funktion is64bit. My code is this:
int main() < uint32_t msr = assembleMSR( 0, 0, 0, 0 ); printf("assembled MSR is %#x, should be 0\n", msr); printf("is64BitMode(&msr) should be 0, is %d\n", is64BitMode(&msr)); printf("is64BitMode(&msr) should my EXAMPLE, is %d\n", is64BitMode(&msr2)); enableInts( &msr); printf("MSR with ints enabled is %#x, should be 0x8000\n", msr); return 0; >int is64BitMode ( uint32_t *MSR ) < int longi=sizeof(MSR); printf("longi de size of%d\n", longi); printf("%d\n", __WORDSIZE);// with this sentence i know that my cpu is running on 64 bits. (void) MSR; return 0; /* TODO */ >
2 Answers 2
Using uname:
You can check whether your processor is 64bits or not using uname :
And with the option -r , you can check if the kernel is 32 or 64 bits:
Using lscpu:
You will be able to know the supported modes but not the used mode:
% lscpu Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit .
Other solutions:
As Zegar suggested in his answer, you can also use grep flags /proc/cpuinfo and look for the lm flag. Or use lshw .
@Zegar he wants to know if its linux » is running in 64 bit mode.». Not if its system could run in 64bit mode.
Ok as far as I understand he asked about I’m looking for a way to know if the cpu of my linux system is running in 64 bit mode. But ok. It’s better when he can select from both of our answers 🙂
If you want to determine CPU’s possibilities:
And then you will observe result:
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx lm constant_tsc pni monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr lahf_lm flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx lm constant_tsc pni monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr lahf_lm flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx lm constant_tsc pni monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr lahf_lm flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx lm constant_tsc pni monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr lahf_lm
If flag lm is present that means Long mode cpu — 64 bit CPU.
Alternatively you can use command:
It’ll produce clear result, on 32bit kernel e.g:
# 32-bit Kernel $ lshw -class cpu *-cpu:0 description: CPU product: Intel(R) Core(TM)2 CPU 4300 @ 1.80GHz vendor: Intel Corp. physical id: 400 bus info: cpu@0 version: 6.15.2 serial: 0000-06F2-0000-0000-0000-0000 slot: Microprocessor size: 1800MHz width: 64 bits clock: 800MHz capabilities: boot fpu fpu_exception wp vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe x86-64 constant_tsc pni monitor ds_cpl est tm2 ssse3 cx16 xtpr lahf_lm configuration: *-logicalcpu:0 description: Logical CPU physical id: 1.1 width: 64 bits capabilities: logical *-logicalcpu:1 description: Logical CPU physical id: 1.2 width: 64 bits capabilities: logical
# 64-bit Kernel *-cpu description: CPU product: Intel(R) Core(TM) i5 CPU M 560 @ 2.67GHz vendor: Intel Corp. physical id: 6 bus info: cpu@0 version: Intel(R) Core(TM) i5 CPU M 560 @ 2.67GHz slot: None size: 1199MHz capacity: 1199MHz width: 64 bits clock: 133MHz capabilities: fpu fpu_exception wp vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp x86-64 constant_tsc arch_perfmon pebs bts rep_good xtopology nonstop_tsc aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm sse4_1 sse4_2 popcnt aes lahf_lm ida arat tpr_shadow vnmi flexpriority ept vpid cpufreq configuration: cores=2 enabledcores=2 threads=4
If you want to determine your kernel properties:
Use solution of Maxime and use either the uname -m or lscpu .