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
$ nproc --all
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.
$ lscpu | grep ^CPU\(s\):
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.