Environment
- Red Hat Enterprise Linux 7
- Red Hat Enterprise Linux 6
- Red Hat Enterprise Linux 5
- Red Hat Enterprise Linux 4
Issue
- What command can be run to print the number of CPU sockets on a system?
Resolution
To accurately determine the number of CPU sockets on a system without physically opening and manually inspecting it, one must rely on the system's DMI table (populated by the BIOS). Install the dmidecode package (if necessary) and then, as root, run the following:
# dmidecode -t4 | grep Socket.Designation: | wc -l2
Warning: There have been cases where dmidecode reports incorrect results due to a problem in the firmware or bios. If you suspect that you are getting incorrect output from dmidecode, make sure to update your bios and other relevant firmware.
If all the CPU sockets on the system are filled (i.e., each socket has a processor in it), performing any of the following as a normal user will be sufficient:
Consult the
/proc/cpuinfo
file, e.g.:$ grep physical.id /proc/cpuinfo | sort -u | wc -l
RHEL6 and above: Use the
lscpu
command, e.g.:$ lscpu | grep -i "socket(s)"
RHEL6 and above: Use the
lstopo
command, provided by the hwloc package, e.g.:$ lstopo --whole-system --only Socket
Related: How to find the number of physical cpus, cpu cores, and logical cpus