Using Ubuntu on a PC


The default installation of Ubuntu is optimized for a PC system, so there is not too much that requires modification. Most things that need tuning are physical devices, which are covered in Chapter 3. The only real PC-only functionality that may need tweaking is the use of Ctrl+Alt+Delete.

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.

Warning 

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.

image from book
Tell Init

The init process is the parent of all processes. It manages different run levels and kicks off processes to start and stop at different run levels. For example, run-level 1 is a single-user mode. It contains a minimal number of running processes and is usually used to fix a broken system. Usually Ubuntu operates at run-level 2, supporting multiple users and graphics. To view the current and previous run level, use the runlevel command. (If there was no previous run-level, then N is displayed.)

If you want to tell init to change run levels, use the telinit command. For example, to switch from the current run level to single-user mode, change to a text window (Ctrl+Alt+F1) and use sudo telinit 1 or sudo telinit s.

Running the shutdown command is similar to running sudo telinit 0. Run-level 0 is the shutdown mode.

The file /etc/inittab tells init what to do at each run level, what processes to spawn, and how to handle hardware signals such as Ctrl+Alt+Delete, Alt+UpArrow, and power modes such as low battery. After modifying the inittab, you will need to tell init to re-examine (query) the file. This is done using telinit q.

image from book



Hacking Ubuntu
Hacking Ubuntu: Serious Hacks Mods and Customizations (ExtremeTech)
ISBN: 047010872X
EAN: 2147483647
Year: 2004
Pages: 124
Authors: Neal Krawetz

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net