In several versions of Linux (Debian, CentOS, RHEL, etc) you can use the nproc command to find the number of processing units available on the machine.

# nproc
4