Get CPU Clock Speed on Linux

Get CPU Clock Speed on Linux

The clock speed of the CPU, also known as the CPU frequency or clock rate, is a critical aspect of the computer's performance. It determines how quickly the processor can execute instructions and is a fundamental metric for understanding the system's capabilities. Knowing how to check the CPU clock speed can be useful for various purposes, from troubleshooting performance issues to optimizing the system for specific tasks. This tutorial demonstrates how to get CPU clock speed on Linux.

In a Linux-based operating system, the /proc/cpuinfo file provides information about the CPU and its features on the system, including current clock speed.

Execute the following command to obtain the current clock speed for all CPU threads:

awk -F': ' '/cpu MHz/{print $2}' /proc/cpuinfo

Output example:


Let's break down the command step by step:

  • awk - is a versatile text-processing tool available on Linux.
  • -F': ' - this option sets the field separator as a colon followed by space. It's used to split each line of input into fields.
  • /cpu MHz/ - this is the pattern being searched for in each line of input. It looks for lines containing the text cpu MHz.
  • {print $2} - this is the action to be performed when the pattern is matched. It tells awk to print the second field on that line.

To monitor the clock speed continuously over a period of time, we can utilize the watch command:

watch -n1 "awk -F': ' '/cpu MHz/{print \$2}' /proc/cpuinfo"

The command output will update every second. You have the flexibility to adjust the update frequency by changing the value following the -n option.

Leave a Comment

Cancel reply

Your email address will not be published.