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

How To Get HDD Temperature in 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)
17 views

How To Get HDD Temperature in 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/ 9

How to get HDD temperature in Linux - Linux Tutorials ... https://linuxconfig.org/obtain-hard-drive-temperature-i...

Menu

How to get HDD temperature in Linux


10 April 2022 by Luke Reynolds

Depending on your server room conditions it may be important to be informed


about the hard drive temperatures inside of your servers. System administrators may
use Bash and cron to write a simple script that can alert them about sudden
temperature change. Various command line tools such as inxi or hddtemp can
check your HDD temperature and be used inside of a Bash script.

In this tutorial, you will see how to get the temperature of a hard drive disk on a
Linux system. The installation instructions and command examples below will get
you started.

In this tutorial you will learn:

• How to install inxi and hddtemp in Linux


• How to use inxi to get HDD temperature
• How to use hddtemp to get HDD temperature
• How to write an HDD temperature monitoring Bash script

1 of 9 4/7/23, 12:36 PM
How to get HDD temperature in Linux - Linux Tutorials ... https://linuxconfig.org/obtain-hard-drive-temperature-i...

How to get HDD temperature in Linux

So�ware Requirements and Linux Command Line Conventions

Category Requirements, Conventions or So�ware Version Used

System Any Linux distro

So�ware inxi, hddtemp

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


Other
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 HDD temperature tools in Linux

The tools we will be using are not usually included by default on most Linux distros.

2 of 9 4/7/23, 12:36 PM
How to get HDD temperature in Linux - Linux Tutorials ... https://linuxconfig.org/obtain-hard-drive-temperature-i...

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

To install inxi and hddtemp on Ubuntu, Debian, and Linux Mint:

$ sudo apt install inxi hddtemp

To install inxi and hddtemp on Fedora, CentOS, AlmaLinux, and Red Hat:

$ sudo dnf install inxi hddtemp

To install inxi and hddtemp on Arch Linux and Manjaro:

$ sudo pacman -S inxi hddtemp

Get HDD temperature command line examples


First, you can determine the path of your block devices by using commands like
fdisk or lsscsi .

$ sudo fdisk -l
OR
$ lsscsi -g

Hard drives will have a path in the format of /dev/sdX for example.

Example 1 Using the inxi tool now we can determine the temperature of all hard
drives with the following command.

$ sudo inxi -xD


Drives: HDD Total Size: 75.5GB (70.3% used) ID-1: /dev/sda model: HTS721060G9

3 of 9 4/7/23, 12:36 PM
How to get HDD temperature in Linux - Linux Tutorials ... https://linuxconfig.org/obtain-hard-drive-temperature-i...

ID-2: USB /dev/sdb model: TransMemory size: 15.5GB temp: 0C

The hard drive temperature of /dev/sda is 35C. Note that the above command
needs to be run with root administrative privileges.

Example 2 Or to check the temperature of a speci�c block device, just specify that
device in your command. For example, this command checks the temperature of
/dev/sdb .

$ sudo inxi -xD /dev/sdb

Example 3 The same information can be achieved through the hddtemp


command. Here is how to use it.

$ sudo hddtemp /dev/sda


/dev/sda: HTS721060G9SA00: 36°C

Get HDD temperature Bash script


If your intention is to wire a monitoring script to regularly check hard driveʼs
temperature, you can use the below script as your starting point:

1 #!/bin/bash
2
3 temperature=$(hddtemp /dev/sda | cut -d : -f3 | sed 's/[^0-9]*

4 of 9 4/7/23, 12:36 PM
How to get HDD temperature in Linux - Linux Tutorials ... https://linuxconfig.org/obtain-hard-drive-temperature-i...

# REPORT when hard drive's temperature is above 50C

if [ $temperature -ge 50 ]; then


echo "ALERT: hard drive's temperature is above: $temperatu
fi

Closing Thoughts

In this tutorial, you saw how to get the temperature of a hard drive disk on a Linux
system. This is facilitated by the inxi and hddtemp commands, which can easily be
installed via package manager on major Linux distros. You also learned how to adapt
these commands into a Bash script to regularly monitor HDD temperature and
report any major temperature spikes.

Related Linux Tutorials:

• An Introduction to Linux Automation, Tools and Techniques


• Things to do a�er installing Ubuntu 22.04 Jammy Jelly�sh…
• Things to install on Ubuntu 22.04
• Get CPU temperature on Linux
• Ubuntu 20.04 Guide
• Mastering Bash Script Loops
• How to benchmark Disk performance on Linux
• How to dual boot Kali Linux and Windows 10
• Install Arch Linux in VMware Workstation
• How to partition a drive on Linux

System Administration

5 of 9 4/7/23, 12:36 PM
How to get HDD temperature in Linux - Linux Tutorials ... https://linuxconfig.org/obtain-hard-drive-temperature-i...

administration, commands, development, Hardware, installation


How to check HDD �rmware version in Linux
Obtain hard-drive model information using Linux

Comments and Discussions

Start Discussion 0 replies

NEWSLETTER

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.

6 of 9 4/7/23, 12:36 PM
How to get HDD temperature in Linux - Linux Tutorials ... https://linuxconfig.org/obtain-hard-drive-temperature-i...

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

7 of 9 4/7/23, 12:36 PM
How to get HDD temperature in Linux - Linux Tutorials ... https://linuxconfig.org/obtain-hard-drive-temperature-i...

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

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

8 of 9 4/7/23, 12:36 PM
How to get HDD temperature in Linux - Linux Tutorials ... https://linuxconfig.org/obtain-hard-drive-temperature-i...

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

9 of 9 4/7/23, 12:36 PM

You might also like