How to get the number of CPU cores in Linux?

In Linux, the CPU information is stored in /proc/cpuinfo file. You can use programs like awk and grep to extract the number of CPU cores in Linux.

Example:

Check if hyper-threading is enabled in your system:

Get the number of CPU cores in Linux – without hyper-threading:

Get the number of CPU cores in Linux – with hyper-threading:

Leave a Reply