Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the ways to check the status and level of notebook battery from the Linux terminal

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly shows you "what are the ways to view the battery status and grade of notebook from the Linux terminal?" the content is easy to understand and clear, hoping to help you solve your doubts. Let the editor lead you to study and learn "what are the ways to view the battery status and grade of notebook from the Linux terminal?"

Several practical tools for checking battery status under Linux

Upower: a command-line tool that provides an interface to list power supplies in the system.

Acpi: displays information from the / proc or / sys file system, such as battery status or heat information.

Batstat: a command line tool that prints battery status for Linux.

Tlp: can bring you more advanced power management without any configuration changes.

Class file: this sysfs file system is a pseudo file system that provides a kernel data structure interface.

How to use the upower command to check the battery status of a laptop

Upower is a command-line tool that provides an interface to list power supplies in the system. It can control the delay of different operations on your computer, which can save you a lot of power.

Just run the following command in Linux to get the battery and other information it depends on.

$upower-I / org/freedesktop/UPower/devices/battery_BAT0 native-path: BAT0 vendor: SMP model: L14M4P23 serial: 756 power supply: yes updated: Monday 03 December 2018 07:56:18 PM IST (95 seconds ago) has history: yes has statistics: yes battery present: yes rechargeable : yes state: discharging warning-level: none energy: 28.23 Wh energy-empty: 0 Wh energy-full: 52.26 Wh energy-full-design: 60 Wh energy-rate: 10.714 W voltage: 14.819 V time to empty: 2.6 hours percentage: 54% capacity: 87.1% technology: lithium-ion icon-name: 'battery-good-symbolic' History (charge): 1543847178 54.000 discharging History (rate): 1543847178 10.714 discharging

Use the format below to check specific information about the battery.

$upower-I / org/freedesktop/UPower/devices/battery_BAT0 | grep-I "state\ | percentage\ | time to empty" state: discharging time to empty: 2.1 hours percentage: 43%

This is similar to the one above, but runs after the charging cable is plugged in, which is why the charging state is shown below.

$upower-I / org/freedesktop/UPower/devices/battery_BAT0 | grep-I "state\ | percentage\ | time to empty" state: charging percentage: 41% how to use the TLP command to check notebook battery status

TLP is a free and open source versatile command line tool that optimizes laptop batteries without any configuration changes.

TLP can bring more advanced power management to your Linux without understanding any technical details. TLP comes with a configuration that has been optimized for your battery by default, so you can leave it alone after you install it. Although TLP is a tool that can be highly customized to your needs.

TLP is available in the official libraries of most Linux distributions, such as Arch, Debian, Fedora, Gentoo, openSUSE, and so on. Install TLP using the package management of your Linux distribution.

Just run the following command in Linux to get the battery and other dependent information.

$sudo tlp-stat-b muri-TLP 1.1-+ Battery Status/sys/class/power_supply/BAT0/manufacturer = SMP/sys/class/power_supply/BAT0/model_name = L14M4P23/sys/class/power_supply/BAT0 / cycle_count = (not supported) / sys/class/power_supply/BAT0/energy_full_design = 60000 [mWh] / sys/class/power_supply/BAT0/energy_full = 52260 [mWh] / sys/class/power_supply/BAT0/energy_now = 21950 [mWh] / sys/class/power_supply/BAT0/power_now = 10923 [mW] / sys/class/power_supply/BAT0/status = Discharging Charge = 42.0 [%] Capacity = 87.1 [%]

You can also view other information.

$sudo tlp-stat-s Murray-TLP 1.1-+ System InfoSystem = LENOVO Lenovo ideapad Y700-15ISK 80NVBIOS = CDCN35WWRelease = "Manjaro Linux" Kernel = 4.19.6-1-MANJARO # 1 SMP PREEMPT Sat Dec 1 12:21:26 UTC 2018 x 86 million 64 / proc/cmdline = BOOT_IMAGE=/boot/vmlinuz-4.19-x86_64 root=UUID=69d9dd18-36be-4631-9ebb-78f05fe3217f rw quiet resume=UUID=a2092b92-af29-4760-8e68-7a201922573bInit system = systemd Boot mode = BIOS (CSM Legacy) + + TLP StatusState = enabledLast run = 07:16:12 IST, 4362 sec (s) agoMode = batteryPower source = battery`` # how to use the ACPI command to check battery status ACPI represents advanced configuration and power interface Advanced Configuration and Power Interface module They are kernel modules for different ACPI parts. They enable special ACPI functions to add information to `/ proc` or` / sys`. This information can be parsed through the acpid of events or other monitors.

$acpi Battery 0: Charging, 43%, 01:05:11 until charged "`

Check the battery capacity.

$acpi-iBattery 0: Charging, 43%, 01:05:07 until chargedBattery 0: design capacity 3817 mAh, last full capacity 3324 mAh = 87%

Check out more information about batteries and their related information.

$acpi-VBattery 0: Charging, 43%, 01:05:07 until chargedBattery 0: design capacity 3815 mAh Last full capacity 3323 mAh = 87%Adapter 0: on-lineCooling 0: Processor 0 of 10Cooling 1: Processor 0 of 10Cooling 2: Processor 0 of 10Cooling 3: iwlwifi 0 of 19Cooling 4: Processor 0 of 10Cooling 5: iwlwifi no state information availableCooling 6: Processor 0 of 10Cooling 7: Processor 0 of 10Cooling 8: Processor 0 of 10Cooling 9: intel_powerclamp no state information availableCooling 10: x86_pkg_temp no state information availableCooling 11: Processor 0 of 10 how to use the Batstat command to view laptop battery status

Batstat is a command-line tool for printing battery information on Linux terminals.

Status: ChargingMax energy: 50.00 WhEnergy left: 24.50 WhPower Consumption: 26.40 WPercentage left: 49.00%Average power Consumption: 0.00 WTime elapsed: 0: 0:12 since 49.00% = Time = Percent = 0: 0: 049.00% as shown in How to use the sysfs file system to view notebook battery status

The sysfs file system is a pseudo file system that provides kernel data structure interfaces. The files under sysfs provide information about devices, kernel modules, file systems, and other kernel components.

The sysfs file system is usually mounted at / sys. In general, it is automatically mounted by the system, but it can also be mounted manually using commands such as mount-t sysfs sysfs / sys.

Many files in the sysfs file system are read-only, but some are writable, allowing kernel variables to be changed. To avoid redundancy, symbolic links are widely used to connect entries in the number of file systems.

$cat / sys/class/power_supply/BAT0/*051Normal0cat: / sys/class/power_supply/BAT0/device: Is a directory522600006000000026660000SMPL14M4P23cat: / sys/class/power_supply/BAT0/power: Is a directory276560001 756Chargingcat: / sys/class/power_supply/BAT0/subsystem: Is a directoryLi-ionBatteryPOWER_SUPPLY_NAME=BAT0POWER_SUPPLY_STATUS=ChargingPOWER_SUPPLY_PRESENT=1POWER_SUPPLY_TECHNOLOGY=Li-ionPOWER_SUPPLY_CYCLE_COUNT=0POWER_SUPPLY_VOLTAGE_MIN_DESIGN=14800000POWER_SUPPLY_VOLTAGE_NOW=15840000POWER_SUPPLY_POWER_NOW=27656000POWER_SUPPLY_ENERGY _ FULL_DESIGN=60000000POWER_SUPPLY_ENERGY_FULL=52260000POWER_SUPPLY_ENERGY_NOW=26660000POWER_SUPPLY_CAPACITY=51POWER_SUPPLY_CAPACITY_LEVEL=NormalPOWER_SUPPLY_MODEL_NAME=L14M4P23POWER_SUPPLY_MANUFACTURER=SMPPOWER_SUPPLY_SERIAL_NUMBER= 7561480000015840000 and above are all the contents of the article entitled "how to check the status and level of notebook batteries from a Linux terminal" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report