Linux Guide/Runlevels
Starting Linux (Booting)
[edit | edit source]When a computer is turned on, it normally begins the process of "booting" by reading software from the system's hard disk (or other non-volatile storage medium), and loading it into memory and then executing it. In this process the kernel is loaded and then various other system programs may be loaded.
A Linux system can be configured to boot up to one of several available "run levels":
0 Halt the system. 1 Single-user mode (for special administration). 2 Single User Mode with Networking 3 Multi-User Mode - boot up in text mode 4 Not yet Defined 5 Multi-User Mode - boot up in X Windows 6 Reboot.
Debian
[edit | edit source]The following quote from The Debian GNU/Linux FAQ explains how to add a custom procedure to a Debian or Debian based system boot:
Suppose a system needs to execute script foo on start-up, or on entry to a particular (System V) runlevel. Then the system administrator should:
- Enter the script foo into the directory /etc/init.d/.
- Run the Debian command update-rc.d with appropriate arguments, to set up links between the (command-line-specified) directories rc?.d and /etc/init.d/foo. Here, '?' is a number from 0 through 6 and corresponds to each of the System V runlevels.
- Reboot the system.
The command update-rc.d will set up links between files in the directories rc?.d and the script in /etc/init.d/. Each link will begin with a 'S' or a 'K', followed by a number, followed by the name of the script. Scripts beginning with 'S' in /etc/rcN.d/ are executed when runlevel N is entered. Scripts beginning with a 'K' are executed when leaving runlevel N.