How to find fan speed in Linux for CPU and GPU

last updated in Categories , , , , ,

What commands I need to type to find out fan speed for GPU and CPU in Linux?

You need to use Linux monitoring sensors software called lm_sensors. It is an open-source software that provides commands and drivers for monitoring CPU/GPU temperatures, voltage, and fan speed. Once lm_sensors installed, we can use System Monitor GUI frontend for KDE or GNOME to get data. Let us see how to install lm_sensors and find out fan speed on Linux operating systems using the CLI.

How to find fan speed in Linux

The procedure to find fan speed on Linux is as follows:

  1. First, install lm-sensors package using package manager.
  2. Configure sensors by running sudo sensors-detect command.
  3. Save the configuration file
  4. Finally, run sensors command in Linux to see CPU and GPU temperature, including fan speed.

Let us see all commands and examples in details.

How to install lm-sensors

Type commands as per your Linux distro.

CentOS/RHEL/Oracle Linux

Use yum command as follows:
sudo yum install lm_sensors
Sample outputs:

Last metadata expiration check: 0:13:39 ago on Tuesday 12 November 2019 05:45:06 PM UTC.
Dependencies resolved.
============================================================================================================
 Package               Arch   Version                         Repository                               Size
============================================================================================================
Installing:
 lm_sensors            x86_64 3.4.0-20.20180522git70f7e08.el8 rhui-rhel-8-for-x86_64-baseos-rhui-rpms 152 k
Installing dependencies:
 perl-Scalar-List-Utils
                       x86_64 3:1.49-2.el8                    rhui-rhel-8-for-x86_64-baseos-rhui-rpms  68 k
 perl-IO               x86_64 1.38-416.el8                    rhui-rhel-8-for-x86_64-baseos-rhui-rpms 141 k
 perl-constant         noarch 1.33-396.el8                    rhui-rhel-8-for-x86_64-baseos-rhui-rpms  25 k
 perl-interpreter      x86_64 4:5.26.3-416.el8                rhui-rhel-8-for-x86_64-baseos-rhui-rpms 6.3 M
 perl-threads          x86_64 1:2.21-2.el8                    rhui-rhel-8-for-x86_64-baseos-rhui-rpms  61 k
 perl-PathTools        x86_64 3.74-1.el8                      rhui-rhel-8-for-x86_64-baseos-rhui-rpms  90 k
 perl-Text-Tabs+Wrap   noarch 2013.0523-395.el8               rhui-rhel-8-for-x86_64-baseos-rhui-rpms  24 k
 perl-File-Path        noarch 2.15-2.el8                      rhui-rhel-8-for-x86_64-baseos-rhui-rpms  38 k
 perl-Unicode-Normalize
                       x86_64 1.25-396.el8                    rhui-rhel-8-for-x86_64-baseos-rhui-rpms  82 k
 perl-Exporter         noarch 5.72-396.el8                    rhui-rhel-8-for-x86_64-baseos-rhui-rpms  34 k
 perl-threads-shared   x86_64 1.58-2.el8                      rhui-rhel-8-for-x86_64-baseos-rhui-rpms  48 k
 perl-libs             x86_64 4:5.26.3-416.el8                rhui-rhel-8-for-x86_64-baseos-rhui-rpms 1.6 M
 perl-Carp             noarch 1.42-396.el8                    rhui-rhel-8-for-x86_64-baseos-rhui-rpms  30 k
 perl-parent           noarch 1:0.237-1.el8                   rhui-rhel-8-for-x86_64-baseos-rhui-rpms  20 k
 perl-Errno            x86_64 1.28-416.el8                    rhui-rhel-8-for-x86_64-baseos-rhui-rpms  76 k
 perl-macros           x86_64 4:5.26.3-416.el8                rhui-rhel-8-for-x86_64-baseos-rhui-rpms  72 k
 perl-Socket           x86_64 4:2.027-3.el8                   rhui-rhel-8-for-x86_64-baseos-rhui-rpms  59 k
 lm_sensors-libs       x86_64 3.4.0-20.20180522git70f7e08.el8 rhui-rhel-8-for-x86_64-baseos-rhui-rpms  59 k
 
Transaction Summary
============================================================================================================
Install  19 Packages
 
Total download size: 8.9 M
Installed size: 22 M
Is this ok [y/N]: y

Fedora Linux

Type dnf command:
sudo dnf install lm_sensors

Debian/Ubuntu/Mint Linux

Execute apt command/apt-get command:
sudo apt-get install lm-sensors

OpenSuse/Suse Linux

Type the following zypper command:
sudo zypper in sensors
Sample outputs:

The following 2 NEW packages are going to be installed:
  libsensors4 sensors
 
2 new packages to install.
Overall download size: 167.9 KiB. Already cached: 0 B. After the operation,
additional 472.9 KiB will be used.
Continue? [y/n/v/...? shows all options] (y): y
Retrieving package libsensors4-3.5.0-4.3.1.x86_64
                                          (1/2),  53.8 KiB (105.2 KiB unpacked)
Retrieving: libsensors4-3.5.0-4.3.1.x86_64.rpm ..........................[done]
Retrieving package sensors-3.5.0-4.3.1.x86_64
                                          (2/2), 114.1 KiB (367.7 KiB unpacked)
Retrieving: sensors-3.5.0-4.3.1.x86_64.rpm ..............................[done]
 
Checking for file conflicts: ............................................[done]
(1/2) Installing: libsensors4-3.5.0-4.3.1.x86_64 ........................[done]
(2/2) Installing: sensors-3.5.0-4.3.1.x86_64 ............................[done]

Arch Linux

Execute pacman command:
sudo pacman -S lm_sensors

Setup and configuration

Now, that lm-sensors installed, it is time to run sensors-detect command to detect and generate a list of kernel modules.
sudo lm-sensors
Now, hardware probing should start. Hence, press the [Enter] key to all questions to create /etc/sensors3.conf file. This file used to load Linux kernel modules and start service automatically at boot time. Display /etc/sensors3.conf using the cat command:
cat /etc/sensors3.conf
Sample outputs:

# libsensors configuration file
# -----------------------------
#
# This default configuration file only includes statements which do not
# differ from one mainboard to the next. Only label, compute and set
# statements for internal voltage and temperature sensors are included.
#
# In general, local changes should not be added to this file, but rather
# placed in custom configuration files located in /etc/sensors.d. This
# approach makes further updates much easier.
#
# Such custom configuration files for specific mainboards can be found in
# "configs" directory of lm-sensors package.
#
# Please contribute back a configuration of your board so other users with
# the same hardware won't need to recreate it again and again.

chip "lm78-*" "lm79-*" "lm80-*" "lm96080-*"

    label temp1 "M/B Temp"


chip "w83792d-*"

    label in0 "VcoreA"
    label in1 "VcoreB"
    label in6 "+5V"
    label in7 "5VSB"
    label in8 "Vbat"

    set in6_min  5.0 * 0.90
    set in6_max  5.0 * 1.10
    set in7_min  5.0 * 0.90
    set in7_max  5.0 * 1.10
    set in8_min  3.0 * 0.90
    set in8_max  3.0 * 1.10


chip "w83793-*"

Display fan speed and other info

Type:
sensors
Finding fan speed in Linux
You can use the grep command to filter out data:
sensors | grep -i fan
Our final example includes the watch command that displays fan speed on screen:
watch -n1 -d sensors
watch -n1 -d 'sensors | grep fan'
watch -n1 -d 'sensors | egrep "fan|temp" | grep -v "0.0"'

Graphical front-ends

watch command demo
Run sensors command repeatedly, and show info on screen

Try installing psensor
sudo apt install psensor # Debian/Ubuntu
sudo zypper in psensor # Suse/OpenSUSE
sudo pacman -S psensor # Arch Linux
sudo yum install xsensors # CentOS/RHEL (use xsensors instead of psensor)

Run it:
psensor
## centos/rhel user run ##
xsensors

Graphical front-ends for Linux to read fan and other sensor data
Using GUI tool to show sensor data such as fan speed, GPU/CPU temp and more in Linux

Outputs from the xsensors:
xsenors
xsenors in actions showing wifi, gpu, cpu, fan, battary and other info

Other GUI options

  1. Grab GNOME Sensors Applet
  2. Download KDE Thermal Monitor (Plasma 5 applet)
  3. Xfce4 panel plugin
  4. MATE Sensors Applet
  5. LXPanel plugin

Conclusion

You learned how to monitor temperatures and fan speed. For more information see lm-sensors home page here.

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

Start the discussion at www.nixcraft.com

Historical Comment Archive