Q. How do I display CPU information such as the number of CPUs and their speed?
A. Proc (/proc) file system provides easy information about CPU and their speed.
The proc filesystem is a pseudo-filesystem which is used as an interface to kernel data structures. It is commonly mounted at /proc. Most of it is read-only, but some files allow kernel variables to be changed.
Display the number of processors in Linux
You need to use /proc/cpuinfo file. This is a collection of CPU and system architecture dependent items, for each supported architecture a different list. Two common entries are processor which gives CPU number and bogomips; a system constant that is calculated during kernel initialization. SMP machines have information for each CPU. Type the following command:
$ less /proc/cpuinfo
Output:
processor : 0 vendor_id : GenuineIntel cpu family : 15 model : 4 model name : Intel(R) Xeon(TM) CPU 3.00GHz stepping : 3 cpu MHz : 2992.991 cache size : 2048 KB physical id : 0 siblings : 2 fdiv_bug : no hlt_bug : no f00f_bug : no coma_bug : no fpu : yes fpu_exception : yes cpuid level : 5 wp : yes 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 pni monitor ds_cpl cid bogomips : 5931.00 processor : 1 vendor_id : GenuineIntel cpu family : 15 model : 4 model name : Intel(R) Xeon(TM) CPU 3.00GHz stepping : 3 cpu MHz : 2992.991 cache size : 2048 KB physical id : 0 siblings : 2 ..... ... ....
You can narrow down output with the following command, to display number of processors in the system:
$ grep processor /proc/cpuinfo
See also:
Featured Articles:
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- My 10 UNIX Command Line Mistakes
- Linux: 20 Iptables Examples For New SysAdmins

- 25 PHP Security Best Practices For Sys Admins
- The Novice Guide To Buying A Linux Laptop
- 10 Greatest Open Source Software Of 2009
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- Top 20 OpenSSH Server Best Security Practices
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Linux Video Editor Software
Facebook it - Tweet it - Print it -


{ 21 comments… read them below or add one }
thanks, works
this works, but you have to pay attention, cause not every time it shows correct info. For example i have 2x intel xeon quad core. cpuinfo shows 16 processors???!!
you have 16 virtual processors total…that is correct
2 quads but each of the these physical processors implement hyperthreading
2 x (4×2)=16
Many thanks!
For just the number of CPUs and speed, this may be simpler.
cat /proc/cpuinfo | grep MHz
I have a VPS and am trying to figure out wether I should user prefork.c or worker.c (better with multiple processors I believe) with apache. I’m trying to decide this based on the number of processors I have. However, this is the info I’m getting from the command mentioned above:
processor : 0
vendor_id : GenuineIntel
cpu family : 15
model : 4
model name : Intel(R) Xeon(TM) CPU 2.80GHz
stepping : 1
cpu MHz : 2798.083
cache size : 1024 KB
fdiv_bug : no
hlt_bug : no
f00f_bug : no
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : 5
wp : yes
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 nx constant_tsc up pebs bts p
ni
bogomips : 5630.31
clflush size : 64
power management:
Any thoughts on how to get the info that I’m looking for?
Whether you have multiple processors or not doesn’t affect your choice between worker and prefork. They both will make full use of all your processors.
Worker uses multiple threads within a unix process, so is more efficient. Prefork uses multiple processes, so you have extra overhead.
There is no good reason to use prefork at all on any processor, except if you are running Apache modules which aren’t thread-safe. mod_php is the most common one, but you don’t need to use that as there is mod_fcgid and running PHP under fcgi.
@Walter
A bit late however it might help someone else. I came across this as I was looking into a similar issue. The easiest way is per a forum entry at http://nixcraft.com/getting-started-tutorials/876-display-number-processors-linux.html:
grep -c processor /proc/cpuinfoThis returns the exact number of available cores, virtual or not.
One way to find out how many physical socketed CPUs there are is to eliminate any extra cores:
grep core\ id /proc/cpuinfo | grep -c \ 0$Unfortunately if multiple physical CPUs only have 1 core each this returns zero. The following (clumsy) group of commands will return the number of physical CPUs regardless of if there is only a single core per CPU:
grep core\ id /proc/cpuinfo | grep -c \ 0$ | grep ^0$ >> /dev/null && grep -c processor /proc/cpuinfo || grep core\ id /proc/cpuinfo | grep -c \ 0$Hi Tricky, thanks for the info! My output for these commands is 1, than 0, than 1 again. So I’m guessing my VPS uses 1 single core CPU?
That is correct – however the clumsy command should be run as one very long command all at once and you should only get 1 output result.
Bear in mind that this long command is more informational than useful as it returns the number of processors – however an application should much rather want to know the number of cores.
VPSs rarely get more than one core. If you have a quad-core physical server shared by 16 VPSs it makes no sense to have more than one virtual core assigned to each VPS.
However if you have a single VPS on a quad-core physical server (there are some scenarios where this is a good idea) then it makes sense to have all 4 cores assigned to the single VPS.
Great.. its works for me.. thanks a lot
hi , i am accessing a solaris server from putty. i dont find any cpuinfo file in proc directory, actually proc directory is for storing all fds. How can we find this file there? r tell me how to find CPU information in solaris.
Hello, friends
In the terminal I typed the command
cat /proc/cpuinfo
and I got that:
processor : 0
vendor_id : AuthenticAMD
cpu family : 16
model : 4
model name : AMD Phenom(tm) II X4 940 Processor
stepping : 2
cpu MHz : 800.000
That is just a part of the hole text, but pay attention that: “cpu MHz: 800″. It is not correct, because my CPU speed is 3 GHz. Why is that?
Thanks in advance.
@kishor – Solaris used to also have /proc/cpuinfo. But now, instead, I believe the command to use is “psrinfo -v”
@Hristiyan – You might be using an application such as cpufreq. When your CPU is idle it can automatically throttle your CPU down to the lowest speed it can go in order to save energy (electricity costs/etc) as well as extend the life of the CPU. When your CPU gets really busy and 800MHz isn’t enough it should automatically increase it, possibly in increments, or maybe even straight back up to 3GHz. Google a bit for info on your distribution and CPU throttling and you will probably find relevant information on how to check this.
I could always be wrong though. ;)
Thank you, Tricky, for the answer. I searched some info about my CPU and I found that you are right – 800 MHz is a power saving mode. That’s why CPU info tool displays such frequency.
I was looking for processor architecture. In Ubuntu I find the following 2 command which was useful. These commands were absent in CentOS, RedHat and Slackware.
# lshw
# lscpu
processor : 3
vendor_id : AuthenticAMD
cpu family : 15
model : 65
model name : Dual-Core AMD Opteron(tm) Processor 2220
stepping : 3
cpu MHz : 2792.802
cache size : 1024 KB
physical id : 1
siblings : 2
core id : 1
cpu cores : 2
fpu : yes
fpu_exception : yes
cpuid level : 1
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt
rdtscp lm 3dnowext 3dnow pni cx16 lahf_lm cmp_legacy svm extapic cr8_legacy
bogomips : 5585.25
TLB size : 1088 4K pages
clflush size : 64
cache_alignment : 64
address sizes : 40 bits physical, 48 bits virtual
power management: ts fid vid ttp tm stc
what does cpu cores and siblings mean .
The siblings property is a way for you to see whether or not HyperThreading is in use.
siblings=2 means that 1 physical core is showing in cpuinfo as if it were 2 cores.
See http://www.redhat.com/archives/nahant-list/2006-January/msg00176.html
Hi there , under Ubuntu Maverick 10.10 i used this line to get CPU Speed Info :
dmesg | grep “MHz processor” | cut -d ” ” -f07 | sed ‘s/[.].*//’
But under Ubuntu Natty 11.04 , this dont work , and only show “evbug”
and the “cat /proc/cpuinfo” its not util for me.
HI,
I want to check the load of the CPU’s individually in linux,can any one help me on this..Thanks in advance
Nag: In Fedora 13 you can see the CPU load graphically in real time: System > About This Computer > Resouces > CPU History.