Saturday, July 20, 2013

Understanding Runlevel

Runlevels:
When the system boots up, it queries for the default runlevel, which is defined in the /etc/inittab file. When that default runlevel is decided, the system boots into that particular runlevel. The different runlevels are essentially “states,” which allow services to be started or stopped depending on the runlevel you are using. There are total six runlevels which are shown in the /etc/inittab file.

0 Halt essentially the system is power off
1 Single-user mode is used to enter single-user mode, which you can use to perform maintenance like as reset the root user’s password.
2 Multiuser with partial services without networking.
3 Full multiuser with networking (text mode)
4 Not used
5 Full multiuser graphical mode (provides a GUI desktop login)
6 Reboot

Runlevel Utilities
Let’s now look at the many system utilities that help you manage the system in different runlevels.
1- shutdown     Brings the system to a powered-off state or can reboot the system
2- halt         Powers down the system
3- reboot       Reboots the system
4- poweroff     Works the same as the halt command
5- chkconfig    Manages what runlevels services start and stop at
6- runlevel     Displays the current and previous runlevels
7- init         Changes runlevels
8- ntsysv       Works similarly to chkconfig in that it is a menu-driven service management utility

Let's look some examples:
# shutdown -h now
 complete power off,
# shutdown -r now
reboot the system
# shutdown -h 120
As a final example, delay the shutdown by 2 minutes:

You can also change the current runlevel you’re in by using the init command.
Step 1. Check the runlevel you’re in:
# runlevel
N 5
According to output you can see you are working on runlevel 5.
As an alternative, you can also use the who command to produce the same results:
# who -r
run-level 5 2010-09-05 09:45 last=S
Step 2. Because you are in runlevel 5, change over to runlevel 3:
# init 3
Now you will switch from runlevel 5 to runlevel 3.

No comments:

Post a Comment