disable X on boot in debian

Chasing unstable/sid is fun, but buggy xdm, gdm, kdm, and wdm started during the boot process can bite you bad.


First get the root shell by entering the following at the boot prompt:


     boot: Linux vga=normal s

Here, Linux is the label for the kernel image you are booting; "vga=normal" will make sure lilo runs in normal VGA screen, and "s" (or "S") is the parameter passed to init to invoke single-user mode. Enter the root password at the prompt.


There are few ways to disable all the X starting daemons:

  • run update-rc.d ?dm stop 99 1 2 3 4 5 6 .
  • insert "exit 0" at the start of all /etc/init.d/?dm files.
  • rename all /etc/rc2.d/S99?dm files to /etc/rc2.d/K99?dm.
  • remove all /etc/rc2.d/S99?dm files.
  • run :>/etc/X11/default-display-manager


Here, number in rc2.d must correspond to the runlevel specified in the /etc/inittab. Also ?dm means that you need to run the command multiple times by substituting it with all of the xdm, gdm, kdm, and wdm.


Only the first one in the list is "the one true way" in Debian. The last one is easy but only works on Debian and requires you to set the display manager again later using dpkg-reconfigure. Others are generic methods to disable daemons.


You can still start X with the startx command from any console shell.

Cannot boot the debain system

No problem, even if you didn't bother to make a boot disk during install. If lilo is broken, grab the boot disk from the Debian installation set and boot your system from it. At the boot prompt, assuming the root partition of your Linux installation is on /dev/hda12 and you want runlevel 3, enter:


     boot: rescue root=/dev/hda12 3

Then you are booted into an almost fully functional system using the kernel on the floppy. (There may be minor glitches due to lack of kernel features or modules.)

Recording shell activities in debian

System administration involves much more elaborate tasks in a Unix environment than in an ordinary personal computer environment. Make sure to know the most basic means of configuration in case you need to recover from system trouble. X11-based GUI configuration tools look nice and convenient but are often unsuitable in these emergency situations.


In this context, recording shell activities is a good practice, especially as root.


Emacs: Use M-x shell to start recording into a buffer, and use C-x C-w to write the buffer to a file.

Shell: Use the screen command with "^A H" or use the script command.


     $ script
     Script started, file is typescript
      ... do whatever ...
     $ col -bx <typescript >savefile
     $ vi savefile

The following can be used instead of script:

     $ bash -i 2>&1 | tee typescript

Recording X activities

If you need to record the graphic image of an X application, including an xterm display, use gimp (GUI). It can capture each window or the whole screen. Alternatives are xwd (xbase-clients), import (imagemagick), and scrot (scrot).

Using Alt-SysRq  Key in Debian

Insurance against system malfunction is provided by the kernel compile option "Magic SysRq key". Pressing Alt-SysRq on an i386, followed by one of the keys r 0 k e i s u b, does the magic.

Un`r'aw restores the keyboard after things like X crashes. Changing the console loglevel to `0' reduces error messages. sa`k' (system attention key) kills all processes on the current virtual console. t`e'rminate kills all processes on the current terminal except init. k`i'll kills all processes except init.

`S'ync, `u'mount, and re`b'oot are for getting out of really bad situations.


Debian default installation kernels are not compiled with this option at the time this document is written. Recompile the kernel to activate this function. Detailed information is in /usr/share/doc/kernel-doc-version/Documentation/sysrq.txt.gz or /usr/src/kernel-version/Documentation/sysrq.txt.gz.

mount hard disk image file

If file.img contains an image of hard disk contents and the original hard disk had a disk configuration which gives xxxx = (bytes/sector) * (sectors/cylinder), then the following will mount it to /mnt:


     # mount -o loop,offset=xxxx file.img /mnt

Note that most hard disks have 512 bytes/sector

Popular editors in Linux

Linux offers many alternatives for console text editors. Among them:

  • vim: Powerful and light BSD-heritage editor. VI iMproved.
  • emacs: Ultimate and heavy GNU-heritage editor. RMS (Richard M. Stallman) original.
  • xemacs: Emacs: The Next Generation, originally from Lucid.
  • mcedit: Newbie GNU editor. Identical to mc internal editor. 
  • ae: Default small editor (Potato). Avoid this.
  • nano: Default small GNU editor (Woody). Emulates pico.
  • joe: For WordStar or TurboPascal old-timers.
  • jed: Fast, full-featured menu-driven editor with Emacs key bindings.
  • jove: Very small editor with Emacs key bindings.
  • nvi: New vi. Bug-for-bug compatible with the original vi.