Tuesday, 23 February 2016

Modifying Ctrl+Alt+Del behavior in Debian Jessie vs Wheezy

Finally got up to testing Raspbian Jessie and being a mixed user of Linux and Windows ran into an issue with the 'three finger salute' Ctrl-Alt-Del (C-D-A) key combination. In Windows this is normally used to lock up the UI when going away from the computer and often comes automatically 'from the spine'. In Linux it nowadays seems to normally initiates a reboot ...in the windowing systems this usually pops up a dialog asking to confirm but when working in the console only it just reboots. Which is of course fairly annoying when not intentional :|

The previous release of Raspbian - based on Debian Wheezy - is built on the sysvinit style boot and the Ctrl-Alt-Del behavior is defined in the /etc/inittab file and can be disabled by commenting out the line that looks something like:
# What to do when CTRL-ALT-DEL is pressed.
ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now
sudo nano /etc/inittab
*** find the line with 'ctrlaltdel' (Ctrl-W for search)
*** comment out by adding the hash '#' at beginning of line
*** save file (Ctrl-O) and exit (Ctrl-X)
sudo init q
...the last command 're-reads' the inittab file and applies the change.

But Jessie is built on the systemd style boot and there is no more /etc/inittab. Surprisingly I did not find a clear, full answer to this using Google - some links like Securing Debian Manual (4.8 Restricting system reboots through the consol) are outdated for Jessie - some are unanswered - some only offer partial information - and some discuss slightly different variation of behavior wanted. Combining the information from those it appears the behavior is controlled by /lib/systemd/system/ctrl-alt-del.target (not /etc/systemd/system/*):
ls -la /lib/systemd/system/ctrl*

lrwxrwxrwx 1 root root 13 Aug 30 23:04 /lib/systemd/system/ctrl-alt-del.target -> reboot.target
To change this we need to remove the current link and replace:
sudo rm /lib/systemd/system/ctrl-alt-del.target
sudo ln -s /dev/null /lib/systemd/system/ctrl-alt-del.target
sudo systemctl daemon-reload
...so to disable Ctrl-Alt-Del we point the target to /dev/null i.e. to be completely ignored and again the last command 're-reads' the configuration and applies the change.

No comments:

Post a Comment

Note: only a member of this blog may post a comment.