How can I show a custom message before shutting down Linux?
Asked by
Capering
I'm using PikaOS, which is Debian-based, and I'd like to display a simple message such as "turn 'em off" immediately before the computer shuts down. I'm not particular about whether it appears in a terminal, as a notification, or in another convenient format.
Answers
If you want a full-screen visual instead of terminal text, you could invoke a screen locker first, wait briefly, and then shut down. A shell alias could look like `lock; sleep 2; shutdown -h now`, assuming your desktop has a suitable locking command.
Reply to this answer
The `shutdown` command can already display a warning to logged-in users when a delay is specified. Check `man shutdown` for the options supported by your system, then combine that with a custom `wall` message if you want your own wording.
Reply to this answer
You can broadcast a message to logged-in users with `wall "Turn 'em off"`, then run the shutdown command afterward. For example: `wall "Turn 'em off"; sleep 2; shutdown -h now`. This should work on most Debian-based systems.
Reply to this answer
Add your answer
Answers are reviewed before publication.
Capering: Thatโs exactly the kind of simple message I was looking for. The format doesnโt matter much as long as it appears before shutdown.