How do I find out how many CPUs my Linux server has?

To count the number of physical processor sockets being used:

cat /proc/cpuinfo | grep "physical id" | sort | uniq | wc -l

To count the number of physical processor cores:

cat /proc/cpuinfo | egrep "core id|physical id" | tr -d "\n" | sed s/physical/\\nphysical/g | grep -v ^$ | sort | uniq | wc -l

To view the model of CPU:

cat /proc/cpuinfo | grep 'model name' | cut -d: -f2 | uniq

For example, the server below has 2 sockets and 12 cores:

[root@rs6k ~]# cat /proc/cpuinfo | grep "physical id" | sort | uniq | wc -l
2
[root@rs6k ~]# cat /proc/cpuinfo | egrep "core id|physical id" | tr -d "\n" | sed s/physical/\\nphysical/g | grep -v ^$ | sort | uniq | wc -l
12
[root@rs6k ~]# cat /proc/cpuinfo | grep 'model name' | cut -d: -f2 | uniq
 Intel(R) Xeon(R) CPU           X5650  @ 2.67GHz