Ubuntu Ctrl+Alt+Delete (CAD) Key Sequence

|

Trapping Ctrl+Alt+Delete
Different versions of Linux either have the Ctrl+Alt+Delete (CAD) key sequence enabled or disabled. In Ubuntu Dapper Drake, this key sequence is enabled, allowing a quick shutdown and reboot. However, the Gnome desktop intercepts CAD. To reboot, you need to switch to a text window (Ctrl+Alt+F1) and then press CAD.

Since the Gnome desktop intercepts CAD, you can remap this key sequence to run a different command. For example, to bring up the Gnome System Monitor, you can use:

gconftool-2 -t str --set /apps/metacity/global_keybindings/run_command_10 \
'<Control><Alt>Delete'
gconftool-2 -t str --set /apps/metacity/keybinding_commands/command_10 \
"gnome-system-monitor"

The system monitor enables you to see the running processes and selectively kill applications. This is similar to using CAD under Microsoft Windows to bring up the System Monitor.

Unfortunately, the reboot command runs as root, so you cannot make CAD run /sbin/reboot. However, you can use gksudo (a graphical front-end to sudo) to prompt you for your password and then run reboot as root:

gconftool-2 -t str --set /apps/metacity/keybinding_commands/command_10 \
"gksudo reboot"



Disabling Ctrl+Alt+Delete
Sometimes you may want to prevent CAD from rebooting the system. For example, a critical server may have CAD disabled to prevent someone from playing with the keyboard and cycling the system.

1. Edit the /etc/inittab file.
sudo vi /etc/inittab

2. Find the line that says:
ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now
This line says, for all init levels (1, 2, … 5), run the shutdown command and reboot now.

3. To disable CAD, comment out the line by inserting # at the beginning of the line.
#ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now

4. To alter the CAD action, change the /sbin/shutdown command to run your own program. For example, you may want to send an alert to an administrator or play some Disco music to let the user know that CAD is outdated.
ca:12345:ctrlaltdel:/usr/bin/play /home/nealk/disco.mp3 > /dev/null
Only one application can use the audio driver at a time, so this will only play music if nothing else is playing at the same time.

5. After changing the inittab file, reload it using: sudo telinit q.


Unmapped keyboard signals can be lost. If you disable CAD, then you may find that you cannot re-enable it without rebooting the system. But if you change the functionality (without disabling the command) then you do not need to reboot. The same is true for power level signals and Alt-UpArrow.

Source of Information : Hacking Ubuntu Serious Hacks Mods and Customizations

0 comments:

Subscribe to Computing Tech

Enter your email address:

Delivered by FeedBurner

Add to Technorati Favorites Top Blogs