How to disable CTRL-ALT-DEL from rebooting a Linux system
Hitting CTRL-ALT-DELETE on most Linux distributions will start the soft reboot process. Normally I like to disable this (at least on production systems) because someone might make a mistake and reboot the system. Also what I don’t like about this shortcut is that you don’t need to be logged in (no user/password needed - but only console access) to reboot the system.
The action taken for CTRL-ALT-DEL is defined in /etc/inittab and if we will look in that file we will see a line similar to the one from bellow (taken from a Debian system):
# What to do when CTRL-ALT-DEL is pressed.
ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now
On other Linux distributions this might look a little different… anyway we are looking for the line containing ctrlaltdel in /etc/inittab. Here is another example: on RedHat based systems this line will look like:
ca::ctrlaltdel:/sbin/shutdown -t3 -r now
If we want to disable this action we only have to change this line. We can delete it, comment it, or even replace it with something like:
ca:12345:ctrlaltdel:/bin/echo "CTRL-ALT-DEL is disabled"
After making any changes to the inittab file, you will have to tell init to reload it, in order to activate the changes. To do that, simply run as root:
init q >







21st June 2006, 18:48
Thanks for reminding me how to do this. I’ve been meaning to disable C-A-D on a mail server which I recently relocated to a client’s office, in what you could call my attempt at “the poor man’s co-location”.
However, there is one other thing which I would like to change in default settings, and that is the response to a press of the Power switch. Currently, my server simply switches off uncleanly upon pressing the ATX power switch, and checks the disk volumes at startup.
If Windows can trap the power switch press and offer multiple choices such as shut down, standby, hibernate, ask, ignore, …., open-source systems such as Linux and the BSDs certainly ought to have at LEAST similar capabilities…
Any pointers?
Thanks in advance.
(warning: email address used (owh) is a spam magnet that triggers a DISCARD in my MTA settings. Try my first name (all lowercase) instead if you must write to me privately).
21st June 2006, 20:02
Renald,
What you are looking for (to take some action when pressing the power button) can be achieved on a motherboard and power supply that supports the ACPI standard. Here are some short tips on what you need to do:
1. ACPI support enabled in kernel
2. ACPI Daemon that reacts to the events through the /proc interface
3. Create an event for powerbtn (button power.*) that will shutdown (or any other action you like).
event=button power.*
action=/sbin/shutdown -h now
Hopefully this information should help you with this issue… But if you need more details, just let me know and I will try to write a little post on this subject…
22nd June 2006, 05:02
Ooooh… ACPI. Well, that might be a problem for my current generation of servers. I built them on legacy hardware, primarily old ASUS motherboards with PIIIs. I’ll have to see if there’s any chance those MBs supported ACPI. If not, then I will revisit the issue when I migrate to more recent hardware…
In any case, thanks for the pointers!
_ renald _
\_____/
26th June 2006, 19:39
Marius,
Your solution works but only once! I havent been able to figure out how to get ctrlaltdelete to work more than once. Running init q again will fix it and I even though about appending that to echo command, but that is rally plain evil.
EP
26th June 2006, 19:48
Hmm… Try to comment all the line out and see if that works.
26th June 2006, 21:14
if i comment it out - then i wont be able to print a message. the idea is that anyone on the system will be reminded that ctrl-alt-del wont work and they should log in as root (if they have access) and use the shutdown command.
by the way, looks like the time is off on the system. it says that today’s comments were posted yesterday. what time zone are you in?
EP
26th June 2006, 22:11
This is strange… It works properly on my side (tested with Debian / Ubuntu). What distribution are you using? does it show an error? or it keeps rebooting even after the change?
About the timezone, the server were this site is hosted is has that set to GMT+3 (as my local timezone).
27th June 2006, 16:29
Aha… I am GMT -5…
I am using SLES 9 (will try to test on redhat as well). Pressing CTRL-ALT-DEL causes the message to print, but only once. Anytime you press CTRL-ALT-DEL again, nothing happens. Only after running init q will this get reset, and CTRL-ALT-DEL will again print the message (only once, until the next init q…)
EP
28th June 2006, 07:21
Hmm… Very strange. Let me know how that went on RH. I have not tested it myself on Suse and don’t have where to test it at this time…
29th June 2006, 20:31
Well, i tried this on Fedora today and it worked perfectly fine. Simply cant figure out how to resove this with SUSE…
8th August 2007, 20:42
Hi
I’m using SLES9 and I have the same problem with CTRL-ALT-DEL. Has anyone figured out how to make the echo to work every time?.
Thxs.
16th November 2007, 15:15
You say “Also what I don’t like about this shortcut is that you don’t need to be logged in (no user/password needed - but only console access) to reboot the system.” This seems a little silly, because someone with console access has full ability to reboot the system anyway (it’s called the power switch). Ctrl-alt-del just lets them do a controlled reboot where the system can settle itself instead of power cycling. So disabling it for this reason is stupid.
(disabling it because you’re worried you’ll hit it by mistake makes more sense.)
19th November 2007, 21:49
Since I pulled this up with a Google search I thought I’d add that after Ubuntu 6.10 “Edgy”, Ubuntu has moved to Upstart as it’s daemon controller. Inittab no longer exists.
Instead you modify /etc/event.d/control-alt-delete. Either delete, comment out these lines:
start on control-alt-delete
exec /sbin/shutdown - now “Control-Alt-Delete pressed”
If you remove the lines, you may want to keep a copy somewhere. I tend to keep copies of config files I change (especially if I’m mucking around out of curiosity) in a directory in my home folder, chown’d to my regular user (because I’m anal like that).
16th July 2008, 20:17
Thanks Marius,
Working mostly with Windoze, I usually press CTRL+ALT+DEL and ENTER to lock the screen when I finish working on a server or when leaving my Workstation.
This is going to save me (and my users) a lot of grief