From c3bec61bddf81141578df62e115d501ff2a071a7 Mon Sep 17 00:00:00 2001 From: Michele Cereda Date: Sun, 14 Jan 2024 17:37:21 +0100 Subject: [PATCH] feat: native but poor method to get a component's temperature in linux --- .../check the temperature of components.md | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/knowledge base/check the temperature of components.md b/knowledge base/check the temperature of components.md index e851f67..3b0ff1f 100644 --- a/knowledge base/check the temperature of components.md +++ b/knowledge base/check the temperature of components.md @@ -1,19 +1,35 @@ # Check the temperature of components -See [lm-sensors], [hddtemp] or [nvme-cli]. +## TL;DR + +```sh +# Show the current temperature of thermal zones in millidegrees C. +cat '/sys/class/thermal/thermal_zone'*'/temp' + +# Show the current temperature of the CPU package in millidegrees C. +grep 'x86_pkg_temp' '/sys/class/thermal/thermal_zone'*'/type' | cut -d':' -f1 | xargs dirname | xargs -I{} cat {}'/temp' + +# Show all types with relative temperature in degrees C. +paste <(cat /sys/class/thermal/thermal_zone*/type) <(cat /sys/class/thermal/thermal_zone*/temp) \ +| column -s $'\t' -t | sed 's/\(.\)..$/.\1°C/' +``` + +See [lm-sensors], [hddtemp] or [nvme-cli] for better ways. ## Sources - [How to check CPU temperature on Ubuntu Linux] +- [Find out CPU temperature from the command-line] -[hddtemp]: hddtemp.md [lm-sensors]: lm-sensors.md [nvme-cli]: nvme-cli.md +[find out cpu temperature from the command-line]: https://www.baeldung.com/linux/cpu-temperature +[hddtemp]: https://wiki.archlinux.org/title/Hddtemp [how to check cpu temperature on ubuntu linux]: https://www.cyberciti.biz/faq/how-to-check-cpu-temperature-on-ubuntu-linux/