- Unix Commands Reference
- Unix Commands - Home
acpid Command in Linux
The acpid command is a daemon (background process) that plays a vital role in managing power consumption and system events on your Linux machine. It leverages the Advanced Configuration and Power Interface (ACPI) standard, allowing the OS to communicate with hardware for efficient power management.
acpid is a crucial component for power management and system event handling in Linux. By understanding its role and how it interacts with ACPI events and user-space programs, you can gain a deeper appreciation for efficient power consumption and a smooth user experience on your Linux system.
Table of Contents
- Understanding acpid Command in Linux
- Prerequisite: Install acpid Command
- acpid Options and Description
- How to use acpid Command in Linux?
Understanding acpid Command in Linux
The "acpid" daemon runs in the background and starts during the system boot process. It monitors the "/proc/acpi/event" file for any ACPI events, and when an event occurs, it executes predefined programs to handle these events. The behavior of "acpid" is controlled by simple configuration files located in "/etc/acpi/events". These files define rules that match specific events to actions. For example, pressing the power button or closing the laptop lid are ACPI events that "acpid" can respond to by executing a shutdown or suspend action.
Prerequisite: Install acpid Command
acpid is usually pre-installed on most Linux distributions as it's a core component for handling power management events. However, if it's missing for some reason, you can install it using your distribution's package manager.
Use the following command syntax replacing <package_manager> with your actual manager and <acpid_package> with the specific package name if different from acpid (e.g., acpid2 on Arch Linux) −
sudo <package_manager> install <acpid_package>
To install "acpid", you can use the package manager of your Linux distribution. For instance, on Debian-based systems, you would use −
sudo apt install acpid
In some cases, the service might start automatically during boot. However, you can manually start and enable it using systemctl (systemd systems) −
sudo systemctl start acpid sudo systemctl enable acpid
It's important to note that not all computers label ACPI events the same way. To determine how your system recognizes these events, you can use the “journalctl -f” command and press the relevant buttons to see how they are logged −
journalctl -f
acpid Options and Description
The acpid command isn't for directly controlling power settings, but it acts as a conductor behind the scenes. It has various options to fine-tune how it operates and interacts with the system. Here's a breakdown of those options in a more user-friendly way −
Configuring the Backstage ( -c, -e )
Options | Description |
---|---|
-c, --confdir directory | This option lets you set the location where acpid looks for its rulebooks. These rulebooks define how acpid should react to different events (like pressing the power button). Imagine it as specifying the script directory for a play. |
-e, --eventfile file | This option tells acpid where to find instructions on what events to listen for. Think of it as the sheet music acpid uses to understand the signals coming from your hardware (battery, buttons, etc.). |
Fine-tuning Communication ( -C, -f, -g, -m, -s, -S )
Options | Description |
---|---|
-C, --clientmax number | This option sets a limit on how many non-administrative programs can connect to acpid at once. Imagine it as controlling the number of backstage crew members who can talk to the conductor (acpid) simultaneously. |
-f, --foreground | By default, acpid runs quietly in the background. This option brings it to the foreground, making its activity visible. Think of it as keeping the conductor on stage, instead of hidden in a pit. |
-g, --socketgroup groupname | This option defines which user group has ownership over the communication channel acpid uses with other programs. Imagine assigning a specific crew member role (like "lighting") to manage communication. |
-m, --socketmode mode | Similar to -g, this option sets the permission level for the communication channel acpid uses. Think of it as defining access levels for the backstage crew (read-only, write access, etc.). |
-s, --socketfile file | This option lets you specify a custom file path for the communication channel acpid uses. Imagine setting up a dedicated backstage intercom system instead of relying on the usual channels. |
-S, --nosocket | This option disables acpid from using a communication channel altogether. Think of it as silencing the backstage intercom and relying on hand signals or runners. |
Logging and Debugging ( -d, -l )
Options | Description |
---|---|
-d, --debug | This option increases the verbosity of acpid's messages, providing more detailed information about its actions. Imagine the conductor giving detailed explanations of every move to help with troubleshooting. |
-l, --logevents | This option instructs acpid to keep a record of all events it encounters, even those without specific actions defined. Think of it as creating a detailed logbook of everything happening on stage, even minor cues. |
Advanced Options ( -n, -r, -t, -v, -h )
Options | Description |
---|---|
-n, --netlink | This option forces acpid to use a specific communication method with the kernel (the core of the operating system). Think of it as using a different backstage communication protocol for specific situations. |
-r, --dropaction action | This option defines a special action to discard certain events acpid might encounter. Imagine the conductor having a pre-arranged signal to ignore minor distractions from the audience. (Use this with caution) |
-t, --tpmutefix | This is a technical option specific to certain ThinkPad laptops to address a mute button quirk. Think of it as a secret handshake between acpid and a specific hardware model. |
-v, --version | This option displays the current version information for acpid. |
-h, --help | This option displays this very information you're reading now, providing a quick reference for all the available acpid options. |
Remember, most users won't need to modify these options unless troubleshooting power management issues or wanting very specific customizations.
How to use acpid Command in Linux?
ACPI is an open industry specification that enables an operating system to control the amount of power distributed to the computer's devices. This ensures efficient power management, which is especially crucial for portable devices like laptops to extend battery life.
Basic Information Display
While acpid primarily runs in the background, it offers advanced command-line options for configuration and debugging purposes. Here's a detailed explanation of each option with examples −
Set the Configuration Directory
By default, acpid uses /etc/acpi/events for configuration files. This -c or --confdir <directory> option allows you to specify an alternative directory containing event handling rules.
Example
To change the directory where "acpid" looks for rule configuration files, use the "-c" or "--confdir" option followed by the directory path. Let’s use a custom directory named "/my_acpi_configs" for event rules −
sudo acpid -c /my_acpi_configs
Caution
Modifying configuration files can significantly impact system behavior. Proceed with caution and consult your distribution's documentation for specific details about the custom directory structure and expected rule formats.
Set the Group Ownership of the Socket File
acpid uses a socket for communication between itself and user-space programs. This -g or --socketgroup <group> option allows you to specify a group that should own the socket file.
Example
Set the socket file group to the "power" group −
sudo acpid -g power
Note − This option requires root privileges for execution.
Set the Permissions for the Socket File
You can control access to the socket file using octal permission codes (e.g., 664) via the “-m or --socketmode <mode>” option.
Example
Grant read/write access to the owner and group, read-only to others (664 permission) −
sudo acpid -m 664
Note − This option requires root privileges for execution.
Specify the Socket File to use for Communication
The default socket file location varies depending on your distribution. The “-s or --socketfile <file>” option allows you to override the default.
Example
Use a custom socket file named "/var/run/my_acpid.sock" as below −
sudo acpid -s /var/run/my_acpid.sock
Note − This option might require adjustments to user-space programs that interact with acpid.
Disable Listening on a UNIX Socket
By default, acpid uses a socket for communication. This -S or --nosocket option instructs it not to use a socket, potentially for specific troubleshooting scenarios.
Example
Disable socket usage (for troubleshooting purposes)
sudo acpid -S
Specify the PID File Location
acpid writes its process ID to a file by default. This -p or --pidfile <file> option allows you to override the default location.
Example
Write the process ID to a file named "/var/run/acpid.pid" as below −
sudo acpid -p /var/run/acpid.pid
Specify the Lockfile to Stop Processing
acpid can use a lockfile to prevent multiple instances from running. This -L or --lockfile <file> option allows you to specify a custom lockfile location.
Example
Use a custom lockfile named "/var/run/acpid.lock" as below −
sudo acpid -L /var/run/acpid.lock
Increase the Debugging Level
For debugging purposes, the “-d” or “--debug” option increases the debug level, and if non-zero, "acpid" will run in the foreground and log to stderr and syslog. This -d or --debug <level> option generates more verbose output for troubleshooting purposes. Higher debug levels might impact performance.
Example
Increase debug level to 2 (use with caution) as below −
sudo acpid -d 2
Note − User can utilize “-l or --logevents” to log all event activity. This can generate a significant amount of log data. Use judiciously for debugging.
Force netlink/input Layer Mode
This -n or --netlink option is for advanced users and might not be applicable to all systems. Consult your distribution's documentation for specific details −
sudo acpid -n
Define a seudo-action to Drop an Event
The “-r or --dropaction <action>” is a highly technical option and is not recommended for general use. Refer to the acpid source code or relevant documentation for detailed information.
Fixup for ThinkPad mute-repeat Behavior
The “-t or --tpmutefix” option addresses a specific issue with ThinkPad laptops and might not be relevant on other systems.
To modify the maximum number of non-root socket connections, use the “-C” or "--clientmax" option followed by the number.
Here's an example of how to define an action for an ACPI event in a configuration file −
/etc/acpi/events/power event=button/power action=/sbin/shutdown -h now
This configuration will shut down the system when the power button is pressed.
Customizing the behavior of "acpid" allows you to tailor your Linux system's power management to your needs. Whether it's handling the power button, lid close action, or any other ACPI event, "acpid" gives you the control to define what happens on your system.
Conclusion
In Linux, the “acpid” command is a daemon that provides intelligent power management by handling ACPI events, which are actions or changes in the system's power state.
Understanding and utilizing the "acpid" command can significantly contribute to the efficiency and customization of your Linux system's power management. With the practical examples provided, you're well on your way to becoming proficient in managing ACPI events on your machine.