How to Get the Processor Speed Information of a Machine

Posted on


The information about the speed of the processor in a machine will be a further discussion and the main content of this article. In order to get the information about the processor speed, there are several ways to achieve it. In other words, those ways for getting the information is by using several commands, tools or utilities available in the machine or in the operating system. Those commands, tools or utilities for printing the information about the speed processor exist in the following description.


Using the command ‘lshw’. According to the information retrieved from the manual page, the command is useful for listing hardware information exist in the machine.  The following is a command execution for getting only the information about the processor speed :

user@hostname:~$ lshw -c cpu | grep capacity
WARNING: you should run this program as super-user.
       capacity: 4GHz
WARNING: output may be incomplete or inaccurate, you should run this program as super-user.

There is an additional filter for printing only the information about the processor speed. There is also an additional parameter along the command to select only the information about the CPU. The parameter is using ‘-c’ where it is an additional parameter for passing only a specific class of hardware. In the above command execution, the class hardware passed along the parameter ‘-c’ is ‘cpu’. So, the information printed as the output of the command execution is only about the CPU. The filter given in the command execution is ‘capacity’. Therefore, the information about the CPU will further filtered only to print the capacity of the CPU.

cat /proc/cpuinfo

Using the content available in the file with the name of ‘cpuinfo’. The file itself exist in a folder location with the name of ‘/proc’. In order to be able to retrieve the information on that file, it needs a command or tool for printing it out. That tool is ‘cat’ where it will print the content of a file. The following is an example for printing the speed processor information using the content available in the file by printing it with ‘cat’ :

root@hostname ~# cat /proc/cpuinfo | grep -i MHz | sort | uniq -w 3
cpu MHz     : 3297.799
root@hostname ~# 

The output above will sort the output and choose only a unique line without further comparing more than 3 characters. The first filter is ‘grep’ which is going to print only the line containing the ‘MHz’ character without having to pay attention to the case type. The additional parameter -i will delightly accept any case type whether it is uppercase or not. Furthermore, the reserved keyword ‘sort’ is for sorting the output provided by the previous filter which is ‘grep’. The last reserved keyword which is ‘uniq’ will print only a unique line comparing no more than 3 characters as it is defined with the additional parameter ‘-w’.


Using the command ‘lscpu’. But the command is not only a single plain command in the command line interface execution. In order to get the desired information about the speed processor, add another command for filtering the information. The filter is ‘awk’ where in the manual page it has a specific function for pattern scanning and processing language. Below is the command combination with additional filter for printing the desired output abot the speed processor information :

root@hostname ~# lscpu | awk '/CPU MHz/ {printf("%.1f GHz",$3/1000); }'
3.1 GHz
root@hostname ~# 

Another pattern for retrieving the speed processor information using the same command, the ‘lscpu’ exist as in the following command execution :

root@hostname ~# lscpu | grep -i mhz
CPU MHz:             3200.042
CPU max MHz:         4000.0000
CPU min MHz:         400.0000
root@hostname ~# 

Leave a Reply