Contact for queries :


  UpComing Live WebEx Workshop Series

working with Linux 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 located, 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 in.
There are six runlevels in total, which are shown in the /etc/inittab file. Each runlevel also has a directory called /etc/rc.d/rc#.d, where # is the runlevel (from 0 to 6).
These different directories contain scripts to tell the system which services should be started or stopped at the particular runlevel.
Let’s look at the different runlevels:

  • 0     Halt
  • 1      Single-user mode
  • 2     Multiuser with partial services
  • 3     Full multiuser with networking (text mode)
  • 4     Not used
  • 5     Full multiuser graphical mode (provides a GUI desktop login)
  • 6     Reboot

The easiest runlevels to understand are 0 and 6.
These two runlevels are called by the same command with different input. In runlevel 0, essentially the system is off (the powered off “state” if you will). In runlevel 6, the system is restarting (the reboot “state”).
Runlevel 1 is used to enter single-user mode, which you would enter if there are issues with the system and you’d like to perform maintenance. You can also reset the root user’s password in this runlevel.
The remaining runlevels—2, 3, and 5—provide various states for different services to run in.
There is also a runlevel 4, but it is unused.
The best way to get a feel for what is started in each of these runlevels is to look in the /etc/rc.d/rc#.d directory for each runlevel. These directories contain files that define whichservices should be started or stopped. These files are actually soft links to the service init scripts on the system.
The /etc/init/rc.conf file shows how each set of scripts is called:

# cat rc.conf
# rc – System V runlevel compatibility
# This task runs the old sysv-rc runlevel scripts. It
# is usually started by the telinit compatibility wrapper.
start on runlevel [0123456]
stop on runlevel [!$RUNLEVEL]
console output
exec /etc/rc.d/rc $RUNLEVEL

Runlevel Utilities

Let’s now look at the many system utilities that help you manage the system in different
runlevels. These management commands include the following:

  • shutdown    Brings the system to a powered-off state or can reboot the system
  • halt               Powers down the system
  • reboot          Reboots the system
  • poweroff      Works the same as the halt command
  • chkconfig    Manages what runlevels services start and stop at
  • runlevel       Displays the current and previous runlevels
  • init               Changes runlevels
  • ntsysv         Works similarly to chkconfig in that it is a menu-driven service management utility

To check the current runlevel you’re in, you can use the runlevel command

# runlevel
N 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

You can also change the current runlevel you’re in by using the init command. Before changing runlevels, however, you should check which runlevel you are in by using one of the two previous commands.
Now that you know how to view your current runlevel and how to change to runlevel 0 and 6, let’s look at how to get to the remaining runlevels.
Using the init command, you can change from one runlevel to another. Make sure that you check which runlevel you are currently in first. As already mentioned, runlevel 5 is the default for Red Hat.
Suppose, though, that you would like to drop down to runlevel-3.
Step 1 – Check the runlevel you’re in:

# runlevel
N 5

Step 2 – Because you are in runlevel 5, change over to runlevel 3:

# init 3

After a minute or so, you will be in runlevel 3. Notice the services that are stopped as you move into a lower runlevel.
Step 3. Verify that you are indeed in runlevel 3:

# runlevel
N 3


November 14, 2015

0 responses on "working with Linux runlevels"

Leave a Message

Your email address will not be published. Required fields are marked *


IGURKUL I.T. Training Hub offering various Career Certification courses in Computer Networking, Unix, Linux, Cloud Computing and DevOps Technologies. With its rich experience in IT training service sector, iGURKUL has been able to set Industry best practices in IT Training for the past five years.

In Past five years, more than 5000 professionals have been trained by iGURKUL for System administration, Cloud Computing and DevOps Skill set through our Online Training portal And , each day , more than 10000 working professionals from all over the globe visiting our knowledge base for the best practices and Knowledge learning.

copyright protected - 2011 © igurkul I.T. solutions. All rights reserved.