There are a couple of ways:
lscpu
or more precise lscpu | grep "MHz"
.
This will give you the general MHz for the CPU.
$ lscpu | grep "MHz".
CPU MHz: 1600.000
cat /proc/cpuinfo
or more precise cat /proc/cpuinfo | grep "MHz"
.
This will give you the individual MHz for each CPU Core. So if you have an Core 2 Duo, AMD Bulldozer, Core i7, etc.. it will show the MHz for each core.
$ cat /proc/cpuinfo | grep "MHz"
cpu MHz : 1600.000
cpu MHz : 1600.000
cpu MHz : 1600.000
cpu MHz : 1600.000
cpu MHz : 1600.000
cpu MHz : 1600.000
cpu MHz : 1600.000
cpu MHz : 3400.000
lshw -c cpu
or more precise version: lshw -c cpu | grep capacity
Will give you the general MHz. Same as lscpu
.
$ lshw -c cpu | grep capacity
WARNING: you should run this program as super-user.
capacity: 1600MHz
WARNING: output may be incomplete or inaccurate, you should run this program as super-user.
sudo dmidecode -t processor
or more precise: sudo dmidecode -t processor | grep "Speed"
Will not only give you a MHz in use but also the Maximum you can push / overclock your CPU to.
$ sudo dmidecode -t processor | grep Speed
[sudo] password for cyrex:
Max Speed: 4000 MHz
Current Speed: 2666 MHz
Out of all of this, lshw
and dmidecode
provide the best information out of your CPU.
You can also target the current MHz detected by the kernel by querying the log files:
cat /var/log/dmesg | grep "MHz processor"
- For the current detected MHz speed
cat /var/log/kern.log | grep "MHz processor"
- For the current and past detected MHz speeds. Will not work in some cases, that is why I posted the dmesg
one first.
And that's all I can remember from the top of my head. I am fairly certain there are other ways, just don't remember right now. Of course, talking about terminal ways.
Note: All the commands above will also give you the CURRENT cpu Hertz, meaning, if you expect to see the same one on lscpu
and when doing the cat /proc/cpuinfo
it will be near impossible. you CAN compare the maximum because that should show the same for any of the ways you can analyze the CPU, but the current will always be literally "the current CPU hertz" at the moment you execute it. Lastly do note that dmidecode reads information from the ACPI tables which is not always the same as the real time ones done by the other tools.