How can I check the number of CPU cores on CentOS?
You can use the following command in CentOS to check the number of CPU cores:
- Use the lscpu command:
lscpu
This command will provide detailed CPU information, including the number of cores.
- Read the /proc/cpuinfo file using the cat command.
cat /proc/cpuinfo | grep processor | wc -l
This command retrieves information from the /proc/cpuinfo file, searches for the keyword “processor” using a pipe and the grep command, and then calculates the number of cores using the wc command.
- nproc command:
nproc
This command will directly display the number of CPU cores.
All three methods can accurately display the number of CPU cores.