Aug 242007

Sponsored Link

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.

 Posted by at 7:04 am

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

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

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

  3. 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. > 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. 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. 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. you say: how to display the _number_ :)
    $ grep -c processor /proc/cpuinfo

  8. 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

    Now lets determine how many cores we have:

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

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

  9. Great. I was looking for this. Thanks.

 Leave a Reply



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