Ubuntu 24.04 LTS: Power Button Pressed Briefly Immediately Shuts Laptop
In this article, we will discuss how to configure Ubuntu 24.04 LTS to immediately shut down the laptop when the power button is pressed briefly, even when the laptop is locked. This is a common request for users who want to quickly shut down their laptops without having to log in or wait for the system to shut down gracefully.
Understanding the Power Button Behavior
By default, Ubuntu is configured to perform a safe shutdown when the power button is pressed. This means that the system will prompt the user to save any open files and then shut down gracefully. However, this behavior can be changed to immediately shut down the system when the power button is pressed.
Configuring the Power Button Behavior
To configure the power button behavior in Ubuntu 24.04 LTS, follow these steps:
Open the Terminal application.
Edit the
/etc/systemd/logind.conffile using a text editor such as nano:sudo nano /etc/systemd/logind.confThis file contains the configuration settings for the systemd-logind service, which manages user sessions and the power button behavior.
Find the
HandlePowerKeysetting and change its value topoweroff:HandlePowerKey=poweroffThis will configure the system to immediately shut down when the power button is pressed.
Save the changes and exit the text editor.
Restart the systemd-logind service to apply the changes:
sudo systemctl restart systemd-logind
Testing the Power Button Behavior
After making the changes, test the power button behavior by pressing the power button briefly. The system should immediately shut down without any prompts or delays.
Ubuntu 24.04 LTS can be configured to immediately shut down when the power button is pressed briefly.
This can be done by editing the
/etc/systemd/logind.conffile and changing theHandlePowerKeysetting topoweroff.The changes can be tested by pressing the power button briefly and observing whether the system immediately shuts down.