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.

Step-by-step video guide:

Steps to check battery status in Linux:

  1. Open the terminal on your Linux system.
  2. 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.

  3. 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.

  4. 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.

  5. 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.

  6. 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.

  7. 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.

  8. 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.

  9. 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.

Discuss the article:

Comment anonymously. Login not required.