How do I find out the number of CPU cores available under HP x86_64 Linux serer running on RHEL / Debian Linux 6.x?
You can use the lscpu or nproc command to display the number of processing units available to the current process, which may be less than the number of online processors (please note that not all server supports hotplug a CPU on a running Linux system).
| Tutorial details | |
|---|---|
| Difficulty | Easy |
| Root privileges | Yes |
| Requirements | None |
The proc file system is a pseudo-file system which is used as an interface to kernel data structures. It is commonly mounted at /proc. The /proc/cpuinfo file is nothing but a collection of CPU and system architecture dependent items, for each supported architecture a different list. Two common entries are processor which gives CPU number and bogomips; a system constant that is calculated during kernel initialization. SMP machines have information for each CPU.
nproc Example
The nproc command shows the number of processing units available:
# nproc
Sample outputs:
8
lscpu Command
lscpu gathers CPU architecture information form /proc/cpuinfon in human-read-able format:
# lscpu
Sample outputs:
Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Byte Order: Little Endian CPU(s): 8 On-line CPU(s) list: 0-7 Thread(s) per core: 1 Core(s) per socket: 4 CPU socket(s): 2 NUMA node(s): 1 Vendor ID: GenuineIntel CPU family: 6 Model: 15 Stepping: 7 CPU MHz: 1866.669 BogoMIPS: 3732.83 Virtualization: VT-x L1d cache: 32K L1i cache: 32K L2 cache: 4096K NUMA node0 CPU(s): 0-7
/proc/cpuinfo
The /proc/cpuinfo and sysfs stores info about your CPU architecture ike number of CPUs, threads, cores, sockets, NUMA nodes, information about CPU caches, CPU family, model, bogoMIPS, yte order and much more:
# less /proc/cpuinfo
Check out related media
Here is a quick demo of lscpu and /proc/cpuinfo commands:
You should follow me on twitter here or grab rss feed to keep track of new changes.
Featured Articles:
- 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012

- My 10 UNIX Command Line Mistakes
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- The Novice Guide To Buying A Linux Laptop












{ 7 comments… read them below or add one }
Useful! You can also press ’1′ when you run ‘top’ to get core info.
Great but… there is a but… You didn’t said that “lscpu” and “nproc” are only available on Debian like Linux !
On one on my Ubuntu VM :
On a Redhat Linux :
lscup could be a simple ‘cat /proc/cpuinfo’ as there is no substitute !
and nproc as :
ET voila !
Just to add more one-liners , for RHEl box that do not come with nproc command:
Thanks Pierre, this was extremely helpful :) !!!!!
To find the number of cpu cores,
cat /proc/cpuinfo| grep processor| wc -l
@ Sam :
UUOC
+
useless use of “| wc -l” : the -c option for grep would do the same …
On FreeBSD dmesg |grep package
produces something like
2 package(s) x 6 core(s) x 2 SMT threads