Apr 292015
 

Which Processor Running on Linux?The command line interface is so versatile that you can find considerable information about even the hardware side of your Linux server or desktop.

In this post, we’ll take a look at a bunch of commands that provide details about the CPU inside a Linux computer.

We’ll dig down for information on the CPU vendor, check if it’s 32-bit or 64-bit, look for the number of cores, frequency, cache size and more.

1. Let’s start with lscpu, a favorite of both users and system administrators.

LSCPU Output
A quick glance at the above output tells us that our Linux box has an Intel, quad-core, 64-bit processor running at 2000MHz.

2. Another favorite of system administrators is /proc/cpuinfo.

Use it with the less prefix since the output is big and quickly vanishes beyond the top of the screen.

Using CPUInfo with less

As with the previous command, we see that the output of /proc/cpuinfo provides information about the processor, vendor, cores and frequency.

In the following two examples, we’ll tweak /proc/cpuinfo to get only the information we need.

3. If you’re interested in just knowing the CPU vendor, go with cat /proc/cpuinfo along with with the grep command.

$ cat /proc/cpuinfo | grep vendor | uniq
vendor_id       : GenuineIntel

The output spits out just the vendor name, nothing more.

4. Now that we have the vendor info (above) let’s dig into details of the Intel processor.

$ cat /proc/cpuinfo | grep 'model name' | uniq
model name	: Intel(R) Core(TM)2 Quad CPU    Q9400  @ 2.66GHz

Voila, your PC runs on a Core 2 Quad core Q9400 processor at 2.66GHz. Not the latest and greatest of processors but adequate for most users.

5. Hardinfo is another handy utility that provides a wealth of information about your Linux system.

Although installed on the command line, hardinfo is actually a GTK based GUI utility.

If hardinfo is not installed on your Linux box, you can do so with the following command on your Ubuntu system.

$ sudo apt-get install hardinfo

If you ask me, hardinfo is an embarras de richesses. Besides the CPU, it provides details on most aspects of the Linux box including memory, storage, PCI devices, storage, USB devices etc plus information on the OS, kernel, and networking.

An extremely handy tool, hardinfo also lets you quickly generate a HTML report that you can save to your machine.

I cannot recommend hardinfo strongly enough.

6. lshw (short for list hardware) is another great utility if you’re looking for details on the CPU.

$ sudo lshw -class processor
description: CPU
       product: Intel(R) Core(TM)2 Quad CPU    Q9400  @ 2.66GHz
       vendor: Intel Corp.
       physical id: 400
       bus info: cpu@0
       slot: CPU
       size: 2GHz
       capacity: 2GHz
       width: 64 bits
       clock: 1333MHz
       capabilities: x86-64 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 constant_tsc arch_perfmon pebs bts rep_good nopl aperfmperf pni dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm sse4_1 xsave lahf_lm dtherm tpr_shadow vnmi flexpriority cpufreq
       configuration: cores=4 enabledcores=4 threads=4

If you’re looking for information about other hardware aspects too like memory, harddrive, controllers, then I suggest you go with the -short option.

lshw short command

7. Inxi is one of my all time favorite command line tools and I have it running on all my Linux systems.

This is an excellent script that provides information in an easy to understand format.

If you haven’t installed Inxi, I strongly encourage you to do so.

$ inxi -C
CPU: Quad core Intel Core2 Quad CPU Q9400 (-MCP-) cache: 3072 KB flags: (lm nx sse sse2 sse3 sse4_1 ssse3 vmx)
Clock Speeds: 1: 2000.00 MHz 2: 2000.00 MHz 3: 2000.00 MHz 4: 2000.00 MHz

Ubuntu
$ sudo apt-get install inxi

CentOS/Fedora
$ sudo yum install inxi

8. cpuid is another useful command line utility if you’re looking for information on the CPU.

The cpuid command provides CPUID information about Intel, AMD x86, VIA as well as older processors like Cyrix, Transmeta, UMC and NexGen.

Run the command with less to get a readable output.

$ cpuid | less
CPU 0:
vendor_id = "GenuineIntel"
version information (1/eax):
processor type = primary processor (0)
family = Intel Pentium Pro/II/III/Celeron/Core/Core 2/Atom, AMD Athlon/Duron, Cyrix M2, VIA C3 (6)
model = 0x7 (7)
stepping id = 0xa (10)
extended family = 0x0 (0)
extended model = 0x1 (1)
(simple synth) = Intel Core 2 Duo (Wolfdale E0/R0) / Core 2 Quad-Core Q9000 (Yorkfield E0/R0) / Mobile Core 2 (Penryn E0/R0) / Pentium Dual-Core Processor E5000/E600 (Wolfdale R0) / Celeron E
3000 (Wolfdale R0) / Xeon Processor 3100 (Wolfdale E0) / Xeon Processor 3300 (Yorkfield E0/R0) / Xeon Processor 5200 (Wolfdale E0) / Xeon Processor 5400 (Harpertown E0), 45nm
(and more)

cpuid is available for both Ubuntu and CentOS distributions.

$ sudo apt-get install cpuid
$ sudo yum install cpuid

9. 32-bit or 64-bit CPU?
We’ll check out a couple of ways you can ascertain if your processor is 32-bit or 64-bit.

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

Notes
* lm (short for Long mode) – 64 bit CPU
* Real mode – 16 bit CPU
* Protected mode – 32-bit CPU

Here’s another way.

$ cat /proc/cpuinfo |grep 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 syscall nx lm constant_tsc arch_perfmon pebs bts rep_good nopl aperfmperf pni dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm sse4_1 xsave lahf_lm dtherm tpr_shadow vnmi flexpriority
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 syscall nx lm constant_tsc arch_perfmon pebs bts rep_good nopl aperfmperf pni dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm sse4_1 xsave lahf_lm dtherm tpr_shadow vnmi flexpriority
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 syscall nx lm constant_tsc arch_perfmon pebs bts rep_good nopl aperfmperf pni dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm sse4_1 xsave lahf_lm dtherm tpr_shadow vnmi flexpriority
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 syscall nx lm constant_tsc arch_perfmon pebs bts rep_good nopl aperfmperf pni dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm sse4_1 xsave lahf_lm dtherm tpr_shadow vnmi flexpriority

Again, the presence of lm (shown in red on the terminal output on the screen) signals a 64-bit processor.

10. Another CPU identification for your command line arsenal is dmidecode.

Remember to run it with the sudo prefix.

dmidecode command

$ sudo dmidecode -t 4 should give you the same results.

11. A less known command is nproc.

The nproc command displays number of processing units available. Caveat: Be aware that the number of processing units might not always be the same as number of cores.

$ nproc
4

12. uname and getconf are two other commands you might want to look at.

But they’re not as useful as lscpu or /proc/cpuinfo.

If your Linux kernel shows up as 64-bit then you can assume that the CPU is a 64-bit processor.

$ getconf LONG_BIT
64
$ uname -a
Linux michael 3.13.0-37-generic #64-Ubuntu SMP Mon Sep 22 21:28:38 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

But if you’re running a 32-bit OS on a 64-bit processor, be warned that the output could be misleading.

On a parting note, I was surprised that previously working tools like hwinfo are currently not available for both Ubuntu (core repository) and CentOS (I checked in the epel repository).

If you haven’t jumped on the Linux bandwagon yet, I urge you to do so by picking any of the distros from the links in the Download Linux section (see above right column).

Sorry, the comment form is closed at this time.