Skip to content

Ubuntu system temperature script without any software installs

Posted by author

Create a simple bash script/command to check your system temperatures!

Here's a simple bash script to check the temperature of your Ubuntu system without installing any software. You can add this script to your .bashrc file to create an alias for it, making it easier to run.

1paste <(cat /sys/class/thermal/thermal_zone*/type) <(cat /sys/class/thermal/thermal_zone*/temp) | column -s $'\t' -t | sed 's/\(.\)..$/.\1°C/'

And to add an alias for it, open your .bashrc file with a text editor:

1$ nano ~/.bashrc
3# And add the following line at the end of the file:
4alias temps="paste <(cat /sys/class/thermal/thermal_zone*/type) <(cat /sys/class/thermal/thermal_zone*/temp) | column -s $'\t' -t | sed 's/\(.\)..$/.\1°C/'"
6# Save and close the file, then run:
7$ source ~/.bashrc

Now you can run the temps command in your terminal to check the temperature of your system.

This will output the temperature of each thermal zone in your system, along with the type of sensor and the temperature in Celsius. Here's an example output:

1BAT0 42.2°C
2x86_pkg_temp 70.0°C

Source: (CC BY-SA 4.0)

Syntax highlighting by

End of article