Exercise: Viewing Power Status with acpi
A Step-by-Step Introduction
acpi command-line tool.
1 Purpose
This exercise demonstrates how an operating system can query the underlying hardware for critical status information. You will use the acpi command-line tool to inspect specific information about the power and thermal status of the host machine. Instead of viewing all information at once, we will take a step-by-step approach to look at each component that ACPI can report on, providing a clearer understanding of the tool’s capabilities.
2 What You’ll Accomplish
By the end of this exercise, you will be able to:
- Install the
acpiutility on Fedora. - Use specific
acpiflags to view AC adapter, battery, and thermal information individually. - Identify other Linux utilities and methods for retrieving power status information.
This exercise maps to the following program and course learning outcomes:
- Course Learning Outcomes (CLOs):
- 3. Troubleshoot hardware and basic network components: Checking power and thermal status is a fundamental step in troubleshooting performance and stability issues on mobile devices.
This exercise develops the following skills, which align with the O*NET SOC Code 15-1232.00 for Computer User Support Specialists.
| Learning Objective | O*NET KSAs | Technologies Used |
|---|---|---|
Inspect specific power subsystems using acpi. |
Knowledge: Computers & Electronics Skills: Troubleshooting, Systems Analysis |
acpi |
3 Prerequisites
This exercise requires a running Fedora 42 virtual machine with internet access and a user account with sudo privileges. For best results, this exercise should be performed on a laptop computer that has a battery.
4 Step-by-Step Guide
Open a terminal window in your Fedora VM to begin.
4.1 Step 1: Install the acpi Tool
The acpi command is a simple tool for reading information from the ACPI (Advanced Configuration and Power Interface) system. It may not be installed by default.
Install it now using
dnf:sudo dnf install -y acpi
4.2 Step 2: Check AC Adapter Status
Let’s start by checking if the system is running on AC power.
Run the
acpicommand with the-a(or--ac-adapter) flag:acpi -aAnalyze the Output: The result will be either
on-lineoroff-line. This tells you if the AC adapter is currently powering the machine.
4.3 Step 3: Check Battery Status
Next, let’s get the status of the battery.
Run the
acpicommand with the-b(or--battery) flag: and the-i(or--details) flagacpi -biAnalyze the Output: This will show you the battery’s state (
Charging,Discharging, orFull), its current charge percentage, and an estimated time until full or empty.
4.4 Step 4: Check Thermal Status
ACPI also provides access to the system’s thermal zones, typically the CPU temperature.
Run the
acpicommand with the-t(or--thermal) flag:acpi -tAnalyze the Output: This will show you the temperature of one or more thermal zones in degrees Celsius.
4.5 Step 5: Get a Combined View
Finally, the -V flag you used previously is simply a shortcut to show all of this information at once.
- Run the verbose command to see everything together:
sh acpi -V
5 Beyond acpi: Other Power Utilities
While acpi is simple and direct, Fedora includes more powerful and modern tools for power management.
upower: This is the standard command-line tool for interacting with the system’s main power management service. It provides much more detail thanacpi, including battery health, energy capacity, and historical data. You will explore this tool in a later exercise.- The
/sysFilesystem: At the lowest level, all information about your hardware is exposed by the Linux kernel as files in the/sysdirectory. You can read this information directly.
/sys Filesystem
You can get the raw battery percentage by reading a file directly. First, find your battery’s name (usually BAT0 or BAT1):
ls /sys/class/power_supply/Then, use cat to read the capacity file for that battery. This file contains a single number representing the percentage.
# Replace BAT0 if your battery has a different name
cat /sys/class/power_supply/BAT0/capacityThis demonstrates the core Linux philosophy that “everything is a file.”
6 Reflect and Review
Now that you have completed this exercise, reflect on your experience in your Microsoft Teams Student Notebook:
- 3 different
acpiflags you used and what they show. - 2 other ways to get power information in Linux besides
acpi. - 1 question you still have about the ACPI interface.
Answer these questions in your notebook to solidify your understanding:
- What
acpicommand would you use to check only the CPU temperature? - You run
acpi -aand the output isoff-line. What does this mean? - What is one piece of information that
upowercan provide thatacpidoes not? - Why is it useful to look at power information in separate, targeted steps rather than all at once?