How to check the number of CPU cores and usage in Linux?
To check the number of CPU cores in a Linux system, you can use the following command:
- Check the number of CPU cores:
- Count the number of processors listed in the CPU information file.
- View CPU usage:
- View real-time CPU usage using the top command.
Press the number 1 key in the top command interface to display the usage of each CPU core.
- Check the CPU usage with the mpstat command:
mpstat -P ALL - Check the CPU usage with the sar command:
sar -u - Check the CPU usage using the pidstat command:
pidstat -u
In the above commands, the -l option is used to specify the output information level, and the -u option is used to specify the output CPU usage rate. Choose the appropriate command and option to view the CPU usage rate according to actual needs.