Debian Admin

Debian/Ubuntu Linux System Administration Tutorials,Howtos,Tips

  • RSS Subscribe

    subscribe to the Debian Admin RSS feed
  • Sponsors



  • Categories

  • Sponsors

  • Support DebianAdmin

    Amount $:
    Website(Optional):


  • Meta

  • Archives



Howto display the number of processors in Linux

Posted by Admin on August 24th, 2007

If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!

If you’ve just bought a new desktop,laptop or server and the box says the box is powered by 2 processors, you can actually verify that.

Here’s how to display the number of processor of your linux box.

Simply issue the following command as root

# cat /proc/cpuinfo | grep processor

Everything in linux is files. This command simply retrieves the number of processors that linux detected from /proc/cpuinfo and displays it. Usually, the processor number comes at the first set of line from issuing the command.

Here’s what the command returned for me:
~~~~~~~~~~~~~~~~~~~~~~~~
processor : 0
~~~~~~~~~~~~~~~~~~~~~~~~

which means You have 1 processor with a processor ID number 0. Processor counting starts with 0.
So if you have a PC with core duo, you will probably have 2 lines that says 0 and 1.That is 2 processors.

  • Share/Bookmark

Random Posts

8 Responses to “Howto display the number of processors in Linux”

  1. Lev Says:

    Ever heard of hyperthreading? If it’s on in the BIOS, it’ll incorrectly double the number…

  2. Eddie303 Says:

    Lev: I once ate that with some proliant server, it had only one CPU, and because of HyperThreading, I thought there are 2…

  3. Igor Says:

    There is a lot simpler solution. Just type ‘top’ at the command prompt and then press ‘1′ (number one).
    You will see the ACTUAL CPUs listed on the top of the page

  4. Bubax Says:

    > Simply issue the following command as root

    *Not* as root, because:
    # ls -l /proc/cpuinfo
    -r–r–r– 1 root root 0 2007-09-03 15:49 /proc/cpuinfo

    (Unless your system uses other permissions than mine, but I don’t see why it should do that.)

    Misuse of cat:
    > # cat /proc/cpuinfo | grep processor

    Simply use:
    # grep processor /proc/cpuinfo

  5. Bubax Says:

    Your script is broken:

    Warning: session_start() [function.session-start]: Cannot send session cookie – headers already sent by (output started at /home/debianad/public_html/wp-content/plugins/SK2/sk2_second_chance.php:2) in /home/debianad/public_html/wp-content/plugins/pxsmail.php on line 1

    Warning: session_start() [function.session-start]: Cannot send session cache limiter – headers already sent (output started at /home/debianad/public_html/wp-content/plugins/SK2/sk2_second_chance.php:2) in /home/debianad/public_html/wp-content/plugins/pxsmail.php on line 1
    Thank you. Your comment has been approved.

  6. Randall Says:

    If your kernel does not have SMP support compiled in, `cat /proc/cpuinfo` will only show one processor, even if you have more than one cpu.

  7. cbn Says:

    you say: how to display the _number_ :)
    $ grep -c processor /proc/cpuinfo
    2

  8. Tracy Phillips Says:

    You can run the command below and you will see number of physical processors in the server:

    [server][root][~]# grep "^physical is" /proc/cpuinfo | awk '{print $NF}' | uniq | wc -l
    1

    Now lets determine how many cores we have:

    [server][root][~]# cat /proc/cpuinfo | grep processor | wc -l
    4

    So from the above, we are able to determine that we have a single CPU quad core chip.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>