≡ Menu

Linux Display CPU Information Number of CPUs and Their Speed

How do I display CPU information like number of CPUs, threads, cores, sockets, NUMA nodes, information about CPU caches, CPU family, model and stepping and their speed on Linux operating systems?

You need to use Proc (/proc) file system provides information about CPU and their speed which is a pseudo-filesystem. It 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.

Tutorial details
DifficultyIntermediate (rss)
Root privilegesNo
Requirements/proc, ls, and lscpu
Estimated completion timeN/A
You can also use the command called lscpu to display information on CPU architecture on modern Linux distributions.

Task: Display the number of processors in Linux

You need to use the /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:
$ more /proc/cpuinfo
OR
$ cat /proc/cpuinfo
OR
$ less /proc/cpuinfo
Sample outputs:

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 the output with the following commands, to display number of processors in the system:
$ grep processor /proc/cpuinfo

Say hello to lscpu

The lscpu command is CPU architecture information helper and can be found under Fedora Linux / RHEL / CentOS v6+ / Debian Linux v6+ and many other latest distro includes this command.
$ lscpu
Sample outputs:

Architecture:          x86_64
CPU op-mode(s):        32-bit, 64-bit
CPU(s):                8
Thread(s) per core:    2
Core(s) per socket:    4
CPU socket(s):         1
NUMA node(s):          1
Vendor ID:             GenuineIntel
CPU family:            6
Model:                 30
Stepping:              5
CPU MHz:               1199.000
Virtualization:        VT-x
L1d cache:             32K
L1i cache:             32K
L2 cache:              256K
L3 cache:              8192K

Warning : lscput command has bug and sometimes in Xen Dom0 kernel reports wrong data. So please use /proc/cpuinfo for verification purpose.

Video demo: /proc/cpuinfo and lscpu command

See the following video demo:

See also:
Tweet itFacebook itGoogle+ itPDF itFound an error/typo on this page?

{ 35 comments… add one }

  • wessy May 27, 2009, 9:25 am

    thanks, works

  • user July 1, 2009, 6:19 am

    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???!!

    • Vijay Kanta July 22, 2014, 7:24 am

      LOL funny answer, but the programs work fine for me. Thanks cyberciti.

    • Alex October 19, 2014, 9:20 pm

      You actually have 16 cores, 8 phsical, 8 logical, Xeon processors have 2 threads per physical core, so, if you have Quad core, it will show 8 cores :)

  • Blake Acheson July 31, 2009, 5:34 pm

    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

    • user1 September 7, 2013, 9:49 am

      It makes you wonder why he/she even needs two Xeons

  • Dave February 10, 2010, 2:36 pm

    Many thanks!

  • thomasrutter May 5, 2010, 8:12 am

    For just the number of CPUs and speed, this may be simpler.

    cat /proc/cpuinfo | grep MHz

  • Walter Vos May 26, 2010, 7:29 am

    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?

    • mmj September 21, 2010, 3:01 am

      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.

  • Tricky September 20, 2010, 4:49 pm

    @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/cpuinfo
    This 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$

    • Walter Vos September 20, 2010, 5:41 pm

      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?

      • Tricky September 21, 2010, 4:28 pm

        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.

    • arun January 23, 2012, 9:16 am

      Great.. its works for me.. thanks a lot

  • kishor December 12, 2010, 9:48 pm

    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.

  • Hristiyan March 5, 2011, 4:35 am

    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.

  • Tricky March 7, 2011, 12:09 am

    @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. ;)

    • Hristiyan March 9, 2011, 4:11 am

      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.

  • Russell April 27, 2011, 6:17 am

    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

  • Mallik May 18, 2011, 1:13 pm

    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 .

  • Tricky May 18, 2011, 7:05 pm

    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

  • Inukaze October 20, 2011, 12:26 am

    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.

  • Nag January 31, 2012, 10:16 am

    HI,
    I want to check the load of the CPU’s individually in linux,can any one help me on this..Thanks in advance

  • Jack February 2, 2012, 5:14 am

    Nag: In Fedora 13 you can see the CPU load graphically in real time: System > About This Computer > Resouces > CPU History.

  • Mannoj March 6, 2012, 12:34 pm

    I’m not sure how you all the get the output for the number of processes but when I do in my server, I see it in seven entries having processor values like below. In this case can I consider I have 7 processors ? So even if top load avg shows ‘5’, I don’t have to worry…??

    [pprod@ssbank ~]$ grep processor /proc/cpuinfo
    processor : 0
    processor : 1
    processor : 2
    processor : 3
    processor : 4
    processor : 5
    processor : 6
    processor : 7

    • Tricky March 7, 2012, 12:34 am

      Since it is counting from zero, your output is showing 8 entries.

    • Tricky March 7, 2012, 12:44 am

      In theory having a load of 5 can be okay. Its probably better to measure other aspects of the server’s performance against what you really need, such as responsiveness.

      For example if a mail filtering server is slow and this causes a 1-2 minute delay in mail delivery, very few (if any) end-users are going to notice. All you might care about in that instance is how much mail per minute the server can handle and whether or not the server’s spools ever go out of control. The small backlog (thus causing the delay) isn’t good but it is not a mission-critical problem and the end-users are still happy.

      On the other hand, if a web server is slow end-users WILL notice, and they definitely won’t be happy. :)

    • mmj March 7, 2012, 1:02 am

      Load average is only a pretty rough indication of your load. It’s the queue depth, really.

      Hypothetically, close to 1 is ideal – it means your server is cruising along. As to what is too high, that doesn’t just depend on the number of processor cores but also on what exactly you’re doing. A load average of 11 might not faze a particular workload. If your workload is entirely comprised of stuff that does not need to be done immediately – that is, it’s just background processing, then it really doesn’t matter how high this gets.

      Think of it like people waiting in line at the airport, if there are four people serving and four people waiting it’s *okay*. If there are four people serving but usually only around one person waiting it’s ideal. If there are four people serving but 31 people waiting then obviously there’s going to be quite a delay. But you’re not taking into account how quickly each of those 31 people will be served. Hope this analogy helps.

      • Mannoj March 7, 2012, 4:37 am

        The explanation on load avg is quite perfect, but I have read somewhere if the load avg is 2 and it has 2 processor then its fine. If its a single processor then the ideal load avg should be lesser than 1. Not sure if this is how we should assume things against number of processor with load avg. vmstat and iostat shows idle time as 68%. But I don’t see any issues with end user, whereas my top proc is mysql demon for DB, pls see below. It has 5 as load avg and my total no: of procs are 8 so in this case I don’t have to worry according to my above approach, do let me know if I need to worry in the real world.
        Thanks!!

        top – 09:46:06 up 96 days, 13:25, 13 users, load average: 5.05, 4.82, 4.79
        Tasks: 410 total, 1 running, 403 sleeping, 0 stopped, 6 zombie
        Cpu(s): 39.5%us, 15.0%sy, 0.0%ni, 43.9%id, 0.8%wa, 0.1%hi, 0.7%si, 0.0%st
        Mem: 16624824k total, 16273580k used, 351244k free, 249740k buffers
        Swap: 32772332k total, 88k used, 32772244k free, 11028372k cached

        PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
        3125 mysql 25 0 601m 463m 5268 S 385.5 2.9 41175:58 mysqld
        31572 tpos 25 0 1273m 203m 7260 S 16.6 1.3 8:05.54 java

  • electro June 4, 2012, 7:11 pm

    I typed the command known:
    grep -c processor /proc/cpuinfo
    and the result is 4. This number means 4 threads or 2 cores ?

    After that I try command:
    grep CPU /proc/cpuinfo

    and the result is:
    model name : Intel(R) Xeon(R) CPU 5140 @ 2.33GHz
    model name : Intel(R) Xeon(R) CPU 5140 @ 2.33GHz
    model name : Intel(R) Xeon(R) CPU 5140 @ 2.33GHz
    model name : Intel(R) Xeon(R) CPU 5140 @ 2.33GHz

    But if I install and configure nginx from the Debian repository, the OS download the amd64 package? Why? And working properly. Any explanation?

  • Jules June 18, 2012, 11:42 pm

    thanks for the info, just what I needed. Who needs man pages eh? (or a memory for that matter!) :)

  • clark November 15, 2012, 8:40 am

    you can use

    watch “cat /proc/cpuinfo | grep MHz”

    to view ur cpu speed, it’ll refresh every 2.0 secs

  • guy damico May 17, 2014, 12:45 pm

    How can I tell if my processor is PAE capable?
    -Processor-
    Name : Intel(R) Pentium(R) M processor 1.70GHz
    Family, model, stepping : 6, 13, 6 (Pentium III/Pentium III Xeon/Celeron/Core Duo/Core Duo 2)
    Vendor : Intel
    -Configuration-
    Cache Size : 2048kb
    Frequency : 600.00MHz
    BogoMIPS : 1199.83
    Byte Order : Little Endian
    -Features-
    FDIV Bug : no
    HLT Bug : no
    F00F Bug : no
    Coma Bug : no
    Has FPU : yes
    -Cache-
    Cache information not available
    -Capabilities-
    fpu : Floating Point Unit
    vme : Virtual 86 Mode Extension
    de : Debug Extensions – I/O breakpoints
    pse : Page Size Extensions (4MB pages)
    tsc : Time Stamp Counter and RDTSC instruction
    msr : Model Specific Registers
    mce : Machine Check Architeture
    cx8 : CMPXCHG8 instruction
    sep : Fast System Call (SYSENTER/SYSEXIT)
    mtrr : Memory Type Range Registers
    pge : Page Global Enable
    mca : Machine Check Architecture
    cmov : Conditional Move instruction
    clflush : Cache Line Flush instruction
    dts : Debug Store
    acpi : Thermal Monitor and Software Controlled Clock
    mmx : MMX technology
    fxsr : FXSAVE and FXRSTOR instructions
    sse : SSE instructions
    sse2 : SSE2 (WNI) instructions
    ss : Self Snoop
    tm : Thermal Monitor
    pbe : Pending Break Enable
    up : smp kernel running on up
    bts : Branch Trace Store
    est : Enhanced SpeedStep
    tm2 : Thermal Monitor 2

  • Tricky May 19, 2014, 7:43 am

    Hi, Guy

    Based on what you pasted, your processor does not support PAE. Simplest check:
    grep -i pae /proc/cpuinfo

    If there are no results then your processor does not support PAE.

    Other ways to check:
    on Intel’s ARK site
    – the page doesn’t mention PAE at all.
    – the Wikipedia article on PAE – the page specifically mentions that “most” 400MHz-bus Pentium M processors did not support PAE.

  • CyrIng February 2, 2015, 7:05 am

    You can also read the cpuid instruction for PAE. The SysInfo of XFreq is using this instruction to show all features of the processor. The source code can be fetched at code.google.com/p/xfreq

Leave a Comment