how do I view CPU temperatures in ubuntu command line?
Assistant
You can view CPU temperatures in Ubuntu from the command line using several tools. Here are a few commonly used methods:
Method 1: Using lm-sensors
Install lm-sensors:
Open the terminal and install the lm-sensors package if you haven't already:
bash
sudo apt update
sudo apt install lm-sensors
Detect sensors:
After installation, run the following command to detect the sensors on your machine:
bash
sudo sensors-detect
Follow the prompts and answer YES to any questions about probing different drivers.
View CPU temperature:
Once the sensors have been detected, you can view the CPU temperatures using:
bash
sensors
This will display the temperature readings for all detected sensors.
Method 2: Using cat to read from /sys
If your system supports hardware monitoring, you can read the CPU temperature directly from files in the /sys directory:
bash
cat /sys/class/thermal/thermal_zone*/temp
The output will be in millidegrees Celsius (mC), so you may need to divide by 1000 to get degrees Celsius. For example, if the output is 45000, that means the temperature is 45.0°C.
Method 3: Using hddtemp for hard drive temperatures
If you're also interested in temperatures of your hard drives, you can install and use hddtemp:
Install hddtemp:
bash
sudo apt install hddtemp
Check hard drive temperature:
Run hddtemp followed by the device name:
bash
sudo hddtemp /dev/sd*
Method 4: Using psensor (optional GUI approach)
While this is not strictly command-line based, if you prefer a graphical tool, you can install PSensor, which can display CPU temperatures in real-time:
bash
sudo apt install psensor
Then run it from your applications menu.
Conclusion
Using lm-sensors is the most common and versatile method to monitor CPU temperatures from the command line in Ubuntu. By following the steps outlined above, you should be able to easily check your CPU temperature and any other relevant thermal information.