0% found this document useful (0 votes)
9 views

Get CPU Temperature On Linux - Linux Tutorials - Learn Linux Configuration

Uploaded by

John Williams
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Get CPU Temperature On Linux - Linux Tutorials - Learn Linux Configuration

Uploaded by

John Williams
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Get CPU temperature on Linux - Linux Tutorials - Learn... https://linuxconfig.

org/get-cpu-temperature-on-linux

Menu

Get CPU temperature on Linux


9 August 2022 by Korbin Brown

The ability to get the temperature of a key component such as a CPU is important, whether you are gaming, overclocking, or hosting intensive
processes on a critical server for your company. The Linux kernel comes with modules built in that allow it to access onboard sensors within the
CPU. In this tutorial, you will learn how to access these sensors and get the CPU temperature on a Linux system.

There is a program that will work in conjunction with the kernel modules mentioned above to display the readings of the CPU temperature in the
userspace. The program is called lm_sensors. This so�ware allows users to get a readout of the CPU temperature in the command line and
interfaces with several graphical front ends that make displaying temperatures in real time automatic and easy.

In this tutorial you will learn:

• How to install lm_sensors on all major Linux distros


• How to use the sensors command to get CPU temperature
• How to install Conky on all major Linux distros
• How to use Conky to monitor CPU temperature

Get CPU temperature on Linux

1 of 6 4/7/23, 12:33 PM
Get CPU temperature on Linux - Linux Tutorials - Learn... https://linuxconfig.org/get-cpu-temperature-on-linux

So�ware Requirements and Linux Command Line Conventions

Category Requirements, Conventions or So�ware Version Used

System Any Linux distro

So�ware lm-sensors, Conky

Other Privileged access to your Linux system as root or via the sudo command.

# – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
Conventions
$ – requires given linux commands to be executed as a regular non-privileged user

How to install lm_sensors on all major Linux distros

The lm_sensors so�ware allows users to retrieve the temperature of their CPU on Linux. This package is available on all major Linux distros and
can be installed from the default system repositories.

You can use the appropriate command below to install lm_sensors with your systemʼs package manager.

To install lm_sensors on Ubuntu, Debian, and Linux Mint:

$ sudo apt install lm-sensors

To install lm_sensors on Fedora, CentOS, AlmaLinux, and Red Hat:

$ sudo dnf install lm_sensors

To install lm_sensors on Arch Linux and Manjaro:

$ sudo pacman -S lm_sensors

Get CPU temperature from command line


Once the lm_sensors package is installed on your system, you will have access to the sensors-detect command. Running this command in your
terminal will show you the temperature of your CPU cores. As long as you have relatively modern hardware, you will probably have temperature
monitoring capability. If you use a desktop distribution, you will have hardware monitoring support enabled.

$ sudo sensors-detect

The program will pose a number of questions about which sensors to use. It will suggest a best option for each one. If you donʼt know which sensors
to pick, go with the recommendations until the end where it asks if you want to save the con�guration. Always save it. Of course, you can use your
best judgment regarding which sensors to use.

Now you may use the sensors command to see a list of your systemʼs current temperatures.

$ sensors

2 of 6 4/7/23, 12:33 PM
Get CPU temperature on Linux - Linux Tutorials - Learn... https://linuxconfig.org/get-cpu-temperature-on-linux

Here is a snippet of output that was produced on our test system:

k8temp-pci-00c3
Adapter: PCI adapter
Core0 Temp: +32.0°C
Core0 Temp: +33.0°C
Core1 Temp: +29.0°C
Core1 Temp: +25.0°C

nouveau-pci-0200
Adapter: PCI adapter
temp1: +58.0°C (high = +100.0°C, crit = +120.0°C)

DID YOU KNOW?


Incorrectly installed heat sinks, clogged vents, or dust-ridden chassis fans can lead to high temperatures inside your PC, which are a
detriment to the longevity of system components, including the CPU, video card, etc. Your BIOS should have (modern systems do) a
temperature failsafe option: if the temperature reaches a certain threshold, the system will shutdown in order to prevent damage to the
hardware.

To continuously monitor the CPU temperature, you can start lm-sensors as a service.

$ sudo systemctl start lm-sensors

And enable it to start automatically at system boot:

$ sudo systemctl enable lm-sensors

Get CPU temperature from GUI


Conky is a system monitoring program for Linux. It displays a widget on your desktop with relevant information for your system. In this case, we
are interested in using Conky to display the CPU temperature. Since Conky is highly customizable, we can con�gure it to continuously display the
output of the sensors command.

Letʼs start by installing Conky. You can use the appropriate command below to install Conky with your systemʼs package manager.

To install Conky on Ubuntu, Debian, and Linux Mint:

$ sudo apt install conky-all

To install Conky on Fedora, CentOS, AlmaLinux, and Red Hat:

$ sudo dnf install conky

To install Conky on Arch Linux and Manjaro:

$ sudo pacman -S conky

Copy the default Conky con�guration to your home directory. It is better to edit this �le with your custom settings, and to keep the original as a
backup.

$ cp /etc/conky/conky.conf ~/.conkyrc

3 of 6 4/7/23, 12:33 PM
Get CPU temperature on Linux - Linux Tutorials - Learn... https://linuxconfig.org/get-cpu-temperature-on-linux

Open the con�guration �le to make your changes. Since Conky can take input in the form of variables from the execution of command line
programs, thatʼs how you pass sensor information to it.

Running execi sensors in the Conky con�guration will give the output of the sensors. However, that give the whole output, so you may want to
use other command line tools like grep and cut to get the exact output that you want.

Example:

${color grey} System temps:


${execi sensors | grep Temp}

Closing Thoughts
In this tutorial, we saw how to get the CPU temperature on a Linux system. This can be achieved on most Linux distros with the lm-sensors
so�ware. Then, Conky and a number of other GUI utilities can take advantage of lm-sensors in order to display the CPU temperature information.
This provides you with an easy way to get and monitor the temperatures in your system, to ensure that your PC is running as cool as possible.

Related Linux Tutorials:

• Best Linux Distro for Gaming


• Nvidia GeForce GTX 1060 Ethereum Hashrate and Mining…
• Nvidia RTX 3080 Ethereum Hashrate and Mining Overclock…
• An Introduction to Linux Automation, Tools and Techniques
• Linux basic health check commands
• Things to do a�er installing Ubuntu 22.04 Jammy Jelly�sh…
• Things to install on Ubuntu 22.04
• Linux Download
• Best Linux distro for developers
• Manjaro Linux Beginner's Guide

System Administration
administration, applications, commands, Hardware
Linux basic health check commands
Ubuntu 22.04 vs 20.04 – Whatʼs new?

Comments and Discussions

1 reply

Jymm Aug '22


I use GNU Krell Monitors
With a single process, gkrellm manages multiple stacked monitors and supports
applying themes to match the monitors appearance to your window manager, Gtk,
or any other theme.

Continue Discussion

NEWSLETTER

4 of 6 4/7/23, 12:33 PM
Get CPU temperature on Linux - Linux Tutorials - Learn... https://linuxconfig.org/get-cpu-temperature-on-linux

Subscribe to Linux Career Newsletter to receive latest news, jobs, career advice and featured con�guration tutorials.

SUBSCRIBE

WRITE FOR US

LinuxCon�g is looking for a technical writer(s) geared towards GNU/Linux and FLOSS technologies. Your articles will feature various GNU/Linux con�guration
tutorials and FLOSS technologies used in combination with GNU/Linux operating system.

When writing your articles you will be expected to be able to keep up with a technological advancement regarding the above mentioned technical area of
expertise. You will work independently and be able to produce at minimum 2 technical articles a month.

APPLY NOW

TAGS

18.04 administration apache applications backup bash beginner browser centos centos8 commands database debian desktop
development docker error fedora �lesystem �rewall gaming gnome Hardware installation java kali manjaro multimedia networking nvidia programming
python redhat rhel8 scripting security server ssh storage terminal ubuntu ubuntu 20.04 virtualization webapp webserver

ABOUT US

FEATURED TUTORIALS

VIM tutorial for beginners

How to install the NVIDIA drivers on Ubuntu 20.04 Focal Fossa Linux

Bash Scripting Tutorial for Beginners

How to check CentOS version

How to �nd my IP address on Ubuntu 20.04 Focal Fossa Linux

Ubuntu 20.04 Remote Desktop Access from Windows 10

Howto mount USB drive in Linux

How to install missing ifcon�g command on Debian Linux

AMD Radeon Ubuntu 20.04 Driver Installation

Ubuntu Static IP con�guration

How to use bash array in a shell script

Linux IP forwarding – How to Disable/Enable

How to install Tweak Tool on Ubuntu 20.04 LTS Focal Fossa Linux

How to enable/disable �rewall on Ubuntu 18.04 Bionic Beaver Linux

Netplan static IP on Ubuntu con�guration

How to change from default to alternative Python version on Debian Linux

Set Kali root password and enable root login

How to Install Adobe Acrobat Reader on Ubuntu 20.04 Focal Fossa Linux

How to install the NVIDIA drivers on Ubuntu 18.04 Bionic Beaver Linux

How to check NVIDIA driver version on your Linux system

Nvidia RTX 3080 Ethereum Hashrate and Mining Overclock settings on HiveOS Linux

LATEST TUTORIALS

5 of 6 4/7/23, 12:33 PM
Get CPU temperature on Linux - Linux Tutorials - Learn... https://linuxconfig.org/get-cpu-temperature-on-linux

Introduction to Vagrant

Check CPU and RAM usage of a Kubernetes pod

Kubernetes vs Docker, whatʼs the di�erence?

Install and Use MicroK8s on Ubuntu

How to Create and Manage a Pod in Kubernetes

How to Create, Manage, and Expose a Service in Kubernetes

Control CPU and RAM usage in Kubernetes

How to Setup Minikube for Kubernetes

Choosing a Kubernetes Networking Addon

What is Kubernetes used for?

How to create a cron job in Kubernetes

kubeadm vs minikube, pros and cons

How to Create a Kubernetes Cluster

How to use helm package manager for Kubernetes

How to deploy WordPress on a Kubernetes cluster

kubectl command examples (cheat sheet)

How to manage and troubleshoot Kubernetes logs

How to Install Kubernetes on All Linux Distros

How to Manage Kubernetes Clusters With kubectl

How to Deploy an Application in Kubernetes

© 2023 TOSID Group Pty Ltd - LinuxCon�g.org

6 of 6 4/7/23, 12:33 PM

You might also like