How To Find Number Of Cpu Cores?

To get total cpu number in a system there are different method. We can get information from /proc/cpuinfo file but it may be not practical to count number of outputs to get total cpu number. We will use nproc command to get preceise cpu number.

Get Total Cpu Number With nproc

We can get all cpu number with the following command

1

2

$nproc--all

1

Show Total Cpu Number With lscpu

lscpu command provides information about cpu so we can get cpu number by grepping the lscpu output like below.

1

2

$lscpu|grep^CPU\(s\):

CPU(s):1

Keep in mind that we call cpu but actually we can count of cores. As you know new cpus try to maximize total core count where these core’s operate like independent cpus.