PROWAREtech
articles » current » information-technology » linux » setup-and-configure » prevent-power-button-shutdown
Prevent Power Button Shutdown on Ubuntu Server
How to disable the power button on Ubuntu Linux.
To disable the power button so that someone cannot just walk up and turn off the machine, follow these steps:
Edit logind.conf by issuing this command.
sudo nano /etc/systemd/logind.conf
The file may look like this.
[Login] #NAutoVTs=6 #ReserveVT=6 #KillUserProcesses=no #KillOnlyUsers= #KillExcludeUsers=root #Controllers= #ResetControllers=cpu #InhibitDelayMaxSec=5 #HandlePowerKey=poweroff #HandleSuspendKey=suspend #HandleHibernateKey=hibernate #HandleLidSwitch=suspend #PowerKeyIgnoreInhibited=no #SuspendKeyIgnoreInhibited=no #HibernateKeyIgnoreInhibited=no #LidSwitchIgnoreInhibited=yes #IdleAction=ignore #IdleActionSec=30min
Modify the HandlePowerKey= line. Remove the # and replace poweroff with ignore.
[Login] #NAutoVTs=6 #ReserveVT=6 #KillUserProcesses=no #KillOnlyUsers= #KillExcludeUsers=root #Controllers= #ResetControllers=cpu #InhibitDelayMaxSec=5 HandlePowerKey=ignore #HandleSuspendKey=suspend #HandleHibernateKey=hibernate #HandleLidSwitch=suspend #PowerKeyIgnoreInhibited=no #SuspendKeyIgnoreInhibited=no #HibernateKeyIgnoreInhibited=no #LidSwitchIgnoreInhibited=yes #IdleAction=ignore #IdleActionSec=30min
Restart systemd-logind.
sudo systemctl restart systemd-logind
Now, try pressing to power button and it should fail to shutdown the Ubuntu Linux machine.
Comment