I have a miniature PC here with a large and prominent power button on the front which is easy to bump accidentally.

The system is running CentOS 7 with systemd.

I already know that I can set HandlePowerKey=ignore in /etc/systems/login.conf but this disables it entirely.

What is the procedure for addressing this on CentOS?

  • Try using a e.g. sleep 5 script before shutdown Nov 27 '18 at 20:34
  • Headless or DE? (I have a gnome solution that shows a dialog box...)
    – Fabby
    Nov 27 '18 at 21:39
  • This is a CentOS minimal install so there is no desktop environment.
    – Zhro
    Nov 28 '18 at 17:37

Some while ago I created this handy script: https://github.com/stackcoder/doublepress

It can prevent accidental shutdowns by requiring double pressing the power button. It's written for Debian, but I'm pretty sure it can be also installed on CentOS.


You might be able to tackle this via BIOS level setting.

There should be a setting in power or system management with reference to power button. It normally has two options: instant action, and delayed for a couple of seconds.

  • I would agree but there is no such option on this BIOS.
    – Zhro
    Nov 27 '18 at 20:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.