Linux Laptop: Display Battery Status And Thermal Temperature From Command Line

/proc

/sys

ADVERTISEMENTS



Linux Laptop: Display Battery Status And Thermal Temperature From Command Line

Tutorial details Difficulty Easy (rss) Root privileges Yes Requirements None Time 2m

upower command : A command line tool for UPower which provides an interface to enumerate power sources on the system and control system-wide power management.

: A command line tool for UPower which provides an interface to enumerate power sources on the system and control system-wide power management. acpi command : Shows battery status and other ACPI information from /proc and /sys file system.

: Shows battery status and other ACPI information from /proc and /sys file system. /sys/class/power_supply/BAT0/ directory : Store ACPI information about your first battery.

Use upower command to check battery status from command line

How do I find out details about my Linux Laptops temperature, battery status and other information from the command prompt? How can I check battery status using the terminal on Linux?: The information regarding your battery status and ACPI is stored inandfile system. The easiest way to read this information is using the various commands line option tools as well as GUI tool on Linux operating system.

Type the following command

$ upower -i /org/freedesktop/UPower/devices/battery_BAT0

Sample outputs:

native-path: /sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0A:00/power_supply/BAT0 vendor: Samsung SDI model: DELL 1C75X35 serial: 1820 power supply: yes updated: Tuesday 21 January 2014 06:01:52 PM IST (1757 seconds ago) has history: yes has statistics: yes battery present: yes rechargeable: yes state: fully-charged energy: 98.235 Wh energy-empty: 0 Wh energy-full: 98.235 Wh energy-full-design: 98.235 Wh energy-rate: 0.0111 W voltage: 12.864 V percentage: 100% capacity: 100% technology: lithium-ion

Use apci command to check battery status using terminal

The acpi command may not be installed by default so use apt-get command or yum command to install the same:

$ sudo yum install acpitool

OR

$ sudo apt-get install acpitool

Sample outputs from Ubuntu LTS 12.04 laptop:

Reading package lists... Done Building dependency tree Reading state information... Done The following package was automatically installed and is no longer required: nvidia-settings-experimental-310 Use 'apt-get autoremove' to remove them. The following NEW packages will be installed: acpitool 0 upgraded, 1 newly installed, 0 to remove and 4 not upgraded. Need to get 46.3 kB of archives. After this operation, 156 kB of additional disk space will be used. Get:1 http://in.archive.ubuntu.com/ubuntu/ precise/universe acpitool amd64 0.5.1-3 [46.3 kB] Fetched 46.3 kB in 1s (37.6 kB/s) Selecting previously unselected package acpitool. (Reading database ... 539294 files and directories currently installed.) Unpacking acpitool (from .../acpitool_0.5.1-3_amd64.deb) ... Processing triggers for man-db ... Setting up acpitool (0.5.1-3) ...

Linux check battery command

Type the following command:

$ acpi -V

Sample outputs:

Battery 0: Full, 100% Battery 0: design capacity 8400 mAh, last full capacity 8044 mAh = 95% Adapter 0: on-line Thermal 0: ok, 53.5 degrees C Thermal 0: trip point 0 switches to mode critical at temperature 107.0 degrees C Cooling 0: LCD 0 of 15 Cooling 1: Processor 0 of 10 Cooling 2: Processor 0 of 10 Cooling 3: Processor 0 of 10 Cooling 4: Processor 0 of 10 Cooling 5: Processor 0 of 10 Cooling 6: Processor 0 of 10 Cooling 7: Processor 0 of 10

To just see status, enter:

$ acpi

Sample outputs:

Battery 0: Charging, 17%, 01:20:06 until charged

See ac adapter information

$ acpi -a

Sample outputs:

Adapter 0: on-line

The above output indicates that laptop is plugged in use i.e. connected.

Show thermal information

$ acpi -t

Sample outputs

Thermal 0: ok, 39.5 degrees C

To use fahrenheit as the temperature unit:

$ acpi -tf

To use kelvin as the temperature unit:

$ acpi -tk

Use /proc/acpi/ directory to get laptop battery info (deprecated method)

You can browse the same data by visiting /proc/acpi/ directory:

$ cd /proc/acpi/

$ ls -l

Sample outputs:

dr-xr-xr-x 3 root root 0 2010-07-07 14:29 ac_adapter dr-xr-xr-x 3 root root 0 2010-07-07 14:29 battery dr-xr-xr-x 5 root root 0 2010-07-07 14:29 button -r-------- 1 root root 0 2010-07-07 14:29 dsdt dr-xr-xr-x 3 root root 0 2010-07-07 14:29 embedded_controller -r-------- 1 root root 0 2010-07-07 13:14 event -r-------- 1 root root 0 2010-07-07 14:29 fadt dr-xr-xr-x 2 root root 0 2010-07-07 14:29 fan -r--r--r-- 1 root root 0 2010-07-07 14:29 info dr-xr-xr-x 2 root root 0 2010-07-07 14:29 power_resource dr-xr-xr-x 10 root root 0 2010-07-07 14:29 processor -rw-r--r-- 1 root root 0 2010-07-07 14:29 sleep dr-xr-xr-x 3 root root 0 2010-07-07 14:29 thermal_zone dr-xr-xr-x 3 root root 0 2010-07-07 13:14 video -rw-r--r-- 1 root root 0 2010-07-07 14:29 wakeup

OR

$ cat /proc/acpi/thermal_zone/THM/temperature

Sample outputs:

temperature: 55 C

Use /sys/class/power_supply/BAT0/ directory to get battery info

As of Linux kernel 2.6.x you need to use /sys/class/power_supply/BAT0 directory:

$ ls -l /sys/class/power_supply/BAT0

Sample outputs:

total 0 -rw-r--r-- 1 root root 4096 Jan 21 18:13 alarm -r--r--r-- 1 root root 4096 Jan 21 18:01 charge_full -r--r--r-- 1 root root 4096 Jan 21 18:01 charge_full_design -r--r--r-- 1 root root 4096 Jan 21 18:01 charge_now -r--r--r-- 1 root root 4096 Jan 21 18:01 current_now -r--r--r-- 1 root root 4096 Jan 21 18:13 cycle_count lrwxrwxrwx 1 root root 0 Jan 21 18:13 device -> ../../../PNP0C0A:00 -r--r--r-- 1 root root 4096 Jan 21 18:01 manufacturer -r--r--r-- 1 root root 4096 Jan 21 18:01 model_name drwxr-xr-x 2 root root 0 Jan 21 18:13 power -r--r--r-- 1 root root 4096 Jan 21 18:01 present -r--r--r-- 1 root root 4096 Jan 21 18:01 serial_number -r--r--r-- 1 root root 4096 Jan 21 18:01 status lrwxrwxrwx 1 root root 0 Jan 21 18:01 subsystem -> ../../../../../../class/power_supply -r--r--r-- 1 root root 4096 Jan 21 18:01 technology -r--r--r-- 1 root root 4096 Jan 21 18:01 type -rw-r--r-- 1 root root 4096 Jan 21 18:01 uevent -r--r--r-- 1 root root 4096 Jan 21 18:01 voltage_min_design -r--r--r-- 1 root root 4096 Jan 21 18:01 voltage_now

Use GUI tool find out battery status on Linux

The gnome-power-statistics is the gui program for the gnome power management infrastructure. It allows users to visualize the power consumption of laptop hardware. Type the following command to view stats or click on GUI power icon located on right side:

$ gnome-power-statistics

Sample outputs:



Related media

How Do I Get CPU Temperature Data?

See our FAQ: Linux Read CPU Temperature Sensor Chip Data

How Do I Read Hard Disk Temperature?

See our Tip: Linux: Monitor hard disks temperature with hddtemp

See also

Man pages: proc(5)