Many Windows users are familiar with different modes of execution of their operating system:
a. Safe mode
b. Command prompt only
c. Safe mode with network support
d. Safe mode with vga
And other such options that are presented during the boot-up process. Similarly, Linux has different modes of executing as well, which are known as runlevels. But unlike Windows, we can change runlevels on a fly.
Definition for runlevel : The term runlevel refers to a mode of operation in one of the computer operating system that implement Unix System V-style initialization. This system replaces the traditional /etc/rc and /etc/rc.local scripts used in BSD UNIX. Conventionally, seven runlevels exist, numbered from zero to six, plus an alias runlevel named 'S' and/or 's'.
Runlevels control services started by the initialization process. The number of runlevels and services started on those runlevels varies with Linux distributions. Information about the runlevels of a particular distribution is listed in file /etc/inittab.
The contents of the file include the following:
Default runlevel. The runlevels used by RedHat are :
# 0 - Halt (Do not set initdefault to this option.)
# 1 - Single User Mode
# 2 - Multi-user, without NFS (The same as 3, if you do not have networking)
# 3 - Full Multi-user Mode
# 4 - Unused
# 5 - X11
# 6 - Reboot (Do not set initdefault to this option.)
id:3:initdefault: # System initialization. si::sysinit:/etc/rc.d/rc.sysinit
l0:0:wait:/etc/rc.d/rc 0
l1:1:wait:/etc/rc.d/rc 1
l2:2:wait:/etc/rc.d/rc 2
l3:3:wait:/etc/rc.d/rc 3
l4:4:wait:/etc/rc.d/rc 4
l5:5:wait:/etc/rc.d/rc 5
l6:6:wait:/etc/rc.d/rc 6
Runlevel 0 : Is halt mode. Telling init to enter runlevel 0 will cause all processes to be killed off, the filesystems unmounted, and the machine to be halted. This is a perfectly acceptable way to bring down the system. On many laptops and modern desktop computers, this will also cause the machine to be turned off. Different commands to go to runlevel 0.
# halt
# init 0
# telinit 0
# shutdown -h
Now in the above command h is halting and now indicates shutdown the computer now it self no grace/trancision time for example you want to shutdown the command after 60 min so give the below command # shutdown -h +60.
Runlevel 1 : Runlevels 1 and 2 are generally used for debugging purposed only, and are not used during normal operations. Most desktop linux distributions boot into runlevel 5, which starts up the Graphical Login Prompt. This allows the user to use the system with X-Windows server enabled. Most servers boot into runlevel 3, which starts the text based login prompt. Linux runlevels can be changed on the fly using the init tool. If you want to switch from text based operations to the Graphical Interface, you just have to type in 'telinit 5' in the root prompt. This will bring up the Graphical Interface in your system. Each runlevel can be configured by the system administrator. The "/etc/inittab" file has information on which runlevel to start the system at and lists the processes to be run at each runlevel. Each runlevel has its own directory structure where you can define the order in which the services start. These directories are located in the /etc/rc.d/ directory, under which you have rc1.d, rc2.d, rc3.d…. rc6.d. Directories where the number from 0 to 6 that corresponds to the runlevel. Inside each directory are symbolic links that point to master initscripts found in /etc/init.d or /etc/rc.d/init.d. You can also change the runlevel at boot time. If your system uses LILO as the boot manager, you can append the runlevel to the boot command : LILO: linux 3 or LILO: linux 5. If your system uses GRUB, you can change the boot runlevel by pressing the `e’ key to edit the boot configuration. Append the runlevel to the end of the boot command as shown : kernel /vmlinuz ro root=/dev/hda1 5 different linux/unix disterbution's runlevels
Debian Linux :
Debian, as well as most of the distributions based on it, like Ubuntu, does not make any distinction between runlevels 2 to 5. See also the Debian FAQ on booting.
0 - Halt
1 - Single
2 - Full multi-user with display manager (GUI)
3 - Full multi-user with display manager (GUI)
4 - Full multi-user with display manager (GUI)
5 - Full multi-user with display manager (GUI)
6 - Reboot
Red Hat Linux
Red Hat as well as most of its derivatives uses runlevels like this.
0 - Halt
1 - Single
2 - Not used/User definable
3 - Full multi-user NO display manager
4 - Not used/User definable
5 - Full multi-user with display manager (GUI)
6 - Reboot
SUSE Linux
SUSE uses a similar setup as Red Hat :
0 - Halt
1 - Single
2 - Full multi-user with no networking
3 - Full multi-user NO display manager
4 - Not used/User definable
5 - Full multi-user with display manager (GUI)
6 - Reboot
Slackware Linux
Slackware Linux uses runlevel 1 for maintenance, as on other Linux distributions; runlevels 2, 3 and 5 identically configured for a console (with all services active); and runlevel 4 adds the X Window System.
0 - Halt
1 - Single
2 - Full multi-user NO display manager
3 - Full multi-user NO display manager
4 - Full multi-user with display manager (GUI)
5 - Not used/User definable
6 - Reboot
Gentoo Linux
0 - Halt
1 - Single
2 - No network
3 - Full multi-user with display manager
4 - Full multi-user with display manager (Alias for runlevel 3)
5 - Full multi-user with display manager (Alias for runlevel 3)
6 - Reboot
System V Releases 3 and 4
0 - shut down system, power-off if hardware supports it (only available from the console)
1 - single-user mode, all filesystems unmounted but root, all processes except console processes killed.
2 - multi-user mode
3 - multi-user mode with RFS (and NFS in release 4) filesystems exported
4 - multi-user, user-defined
5 - halt the operating system, go to firmware
6 - halt the system, reboot to default runlevel
s, S - identical to 1 except current terminal acts as the system console
Solaris
0 - operating system halted; (SPARC only) drop to OpenBoot prompt
S - single-user with only root filesystem mounted (as read-only)
1 - single-user mode with all local filesystems mounted (read-write)
2 - multi-user with most daemons started.
3 - multi-user, identical to 2 (runlevel 3 runs both /sbin/rc2 and /sbin/rc3), with filesystems exported, plus some other network services started.
4 - alternative multi-user, user defined
5 - shut down, power-off if hardware supports it
6 - reboot
HP-UX
0 - system halted
S - single-user, booted to system console only, with only root filesystem mounted (as read-only)
s - single user, identical to S except the current terminal acts as the system console
1 - single-user with local filesystems mounted (read-write)
2 - multi-user with most daemons started and Common Desktop Environment launched
3 - multi-user, nearly identical to runlevel 2 with NFS exported
4 - multi-user with VUE started instead of CDE
5 - user-defined
6 - user-defined
AIX
AIX does not follow the System V R4 (SVR4) run level specification. It defines run levels from 0 to 9, 0 and 1 are reserved, 2 is the default normal multiuser mode and run levels from 3 to 9 are defined by administrator.
AIX runlevels
ID
Name
Description
0
reserved
1
reserved
2
Normal multiuser mode
default mode
On AIX you can check the current runlevel with the following command: $ who -r