Sunday, December 19, 2010

Number of Processors

If your coworker or colleague ever asked you to find out how many processor does the linux server have, then...

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.


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

[server][root][~]# grep “^physical id” /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

No comments:

Post a Comment