Commands To Check How Many CPUs In Linux
The Linux family of operating systems has been around for ages. Although there may be hundreds of different distributions of the famous operating system, they share a lot of similarity. The most common trait between all distributions is the Linux Kernel. With all of that being said, let's jump straight into the information you need.
Checking the "lscpu" command for number of CPUs
By far, the most common to check for the number of CPUs in Linux is going to be by using the
This command above is available on almost every Linux distribution and comes complete with all of the info you will need. Most notably, you will see a column known as "CPUs," "Threads per core," and "Sockets." The "CPUs" is a count of the number of logical cores.
What are "Threads"? "Threads" are further queues to the CPU logical cores. You should exclude "Threads" when counting CPU resources for performance.
Finally, "Sockets" are the number of Physical CPUs. For example, if you pulled out the CPU from the Server, that would be where the socket is, the hole where the CPU goes on the motherboard. The socket location is important to take into account because the number of sockets can have a performance impact on memory and latency. For example, you wouldn't want a task or virtual machine to exceed multiple sockets as it introduces delay for applications. Sometimes that's unavoidable, but most of the time, you can account for the issue by sizing your servers properly.
Checking Proc/cpuinfo for Hardware details of CPUs
The second available command is the most common checked, querying the /proc directory for direct CPU hardware information. Querying that directory is done with the following command.
Above you'll notice quite a few lines that probably mean nothing to you. What we need to focus on is the row that states "processor." The "processor" row is the count for the number of virtual cores (or threads) starting at zero and counting up by one.
You will also see the "model name" of the CPU, which may or may not be correct if you are on a virtual private server. The reason for that possibly not being accurate is that virtual hosting providers mask the model name to allow for live migration of virtual servers between hosts without downtime.
Powered by WHMCompleteSolution