Linux operating systems provide built-in tools to check detailed battery information. Most Linux distributions support the Advanced Configuration and Power Interface (ACPI) daemon, which allows access to essential battery data. The information is stored in the /sys filesystem, making it accessible directly from the command line. This lets users monitor battery status efficiently without external applications.
In addition to browsing the /sys filesystem, Linux provides tools such as upower and acpi to display battery details more conveniently. These utilities offer real-time data on battery capacity, charge level, and overall health. Using these tools, Linux users can easily retrieve battery-related information from the terminal.
For users who want to regularly check their battery health and capacity, these tools provide a simple and reliable method. Accessing battery information through the terminal is both efficient and accurate. By understanding these utilities, users can monitor their battery's condition, current charge, and overall health, helping them to manage power usage effectively.
Steps to check battery status in Linux:
- Open the terminal on your Linux system.
- Navigate to the /sys/class/power_supply directory to access battery information.
$ cd /sys/class/power_supply/
This directory contains information on power supplies, including the battery. The directory BAT0 is usually used for the primary battery.
- List the contents of the BAT0 directory to see available battery data.
$ ls /sys/class/power_supply/BAT0/ alarm capacity capacity_level charge_full charge_full_design charge_now current_now device present status technology voltage_now
This will display files containing battery data, such as capacity, status, charge_full, and charge_full_design. These files can be accessed to monitor battery information.
- View the battery charge level by reading the capacity file.
$ cat /sys/class/power_supply/BAT0/capacity 85
This will return the current battery percentage. For example, it might output 85 indicating 85% battery charge.
- Check the battery health by comparing the design capacity with the current full charge capacity.
$ cat /sys/class/power_supply/BAT0/charge_full $ cat /sys/class/power_supply/BAT0/charge_full_design 7118000 8157000
The charge_full file shows the current full charge capacity in microamp-hours (mAh), while charge_full_design provides the battery's original design capacity. By comparing these two values, you can estimate the battery's health.
A significant difference between these values indicates battery wear. In this example, the current capacity is 7118 mAh, while the design capacity is 8157 mAh, meaning the battery is around 87% of its original capacity.
- Check the battery status by reading the status file.
$ cat /sys/class/power_supply/BAT0/status Discharging
This file provides the current charging status, such as Charging, Discharging, or Full.
- Install the acpi package if it is not already installed on your system.
$ sudo apt update && sudo apt install acpi
The acpi package is available for most Linux distributions, including Debian-based systems like Ubuntu.
- Use the acpi command to check the current battery status and capacity.
$ acpi --battery --details Battery 0: Discharging, 85%, 02:30:00 remaining Battery 0: design capacity 8157 mAh, last full capacity 7118 mAh = 87%
The output from acpi shows the current battery state and provides details on battery capacity and health.
- For more detailed battery information, including voltage and health, use the upower command.
$ upower -i /org/freedesktop/UPower/devices/battery_BAT0 native-path: BAT0 vendor: Samsung SDI model: DELL TXF9M6C serial: 34075 state: discharging percentage: 85% capacity: 87.2625% voltage: 8.504 V
The upower command provides comprehensive battery details, including model, capacity, voltage, and charge rate.
Mohd Shakir Zakaria is an experienced cloud architect with a strong development and open-source advocacy background. He boasts multiple certifications in AWS, Red Hat, VMware, ITIL, and Linux, underscoring his expertise in cloud architecture and system administration.
Comment anonymously. Login not required.