Subscribe to How-To Geek

Display Number of Processors on Linux

If you’ve just upgraded your Linux box, or you are wondering how many processors a remote server has, there’s a quick and dirty command you can use to display the number of processors.

On Linux, /proc/cpuinfo contains all of the processor information for all current processors in your computer. This will include the speed, the amount of on-chip cache, processor type, and how many cores.

Here’s the command:

cat /proc/cpuinfo | grep processor | wc -l

The command just looks in the /proc/cpuinfo file, pulls out the number of lines containing the word “processor” and passes them into wc (word count), which returns a count of the CPUs in the system.

Here’s what it returned on my remote server:

[root@root]# cat /proc/cpuinfo | grep processor | wc -l

4

Note that if you have a dual-core processor, it will return each core as a separate processor. You can look at the full output of cat /proc/cpuinfo to see if the chips are dual-core.

The Geek is the founder of How-To Geek and a geek enthusiast. This article was written on 02/22/07 and tagged with: Suse Linux, Ubuntu

Daily Email Updates

You can get our how-to articles in your inbox each day for free. Just enter your name and email below:


Name:
Email:
Similar Articles Featured Wiki Articles
Latest Software Reviews Quick Linux Tips
Geek Arcade Popular Forum Threads

Comments (6)

  1. Rayz

    Hi,
    this will give you the same result and saves you having to type a couple of characters

    grep processor /proc/cpuinfo |wc -l

  2. Nate

    This will save you a pipe
    grep -c processor /proc/cpuinfo

  3. Paul Boddie

    Won’t this count CPUs with hyperthreading twice? My computer has one Pentium 4 (Prescott) CPU, but has two processor entries in cpuinfo.

  4. odor

    Well… Sorry to say that it doesn’t work most of the time. Beside multithreadin processors, It is common that entry on a single processor has multiple occurence of word “processor” (both in the procesor identifier and model name.
    On my ancient pemtium M laptop it reports 2 processors because ist modelname is “Intel(R) Pentium(R) M processor 1.73GHz”.

    This might help:
    grep -c ^processor /proc/cpuinfo

  5. Ron

    To get the count of physical CPUs, this works by counting the unique physical ids
    grep “physical id” /proc/cpuinfo |sort -u|wc -l

  6. Alex

    This comment I wrote may also help you (it’s actually for Linux): http://www.howtogeek.com/howto.....ment-64380


Leave a Comment




Leave your friendly comment here.

If you have a computer help question, click here to leave it on the forums instead.

Note: Your comment may not show up immediately on the site.

Sponsored Links
Getting Started
About How-To Geek
What Is That Process?
svchost.exe
jusched.exe
dwm.exe
ctfmon.exe
wmpnetwk.exe
wmpnscfg.exe
rundll32.exe
wfcrun32.exe
Ipoint.exe
Itype.exe
Wfica32.exe
Mobsync.exe
Cmd.exe
Dpupdchk.exe Adobe_Updater.exe

Copyright © 2006-2009 HowToGeek.com. All Rights Reserved.