Linux Changing Run Levels

by on October 16, 2005 · 12 comments· LAST UPDATED October 12, 2011

in , ,

A question from my email bag:

How do changing run levels affect us or our users?

If you are moving to higher run levels, you may make additional services available to users, while moving to a lower run level will causes to services (daemons) to become unavailable. On the production server run level 3 is the normally used and rarely changed. However, some administrative tasks require the administrator to move system to run level 1 i.e single user mode.

Linux Find Out Current Run Level Command

Type the following command:
$ who -r
Sample outputs:

         run-level 2  2011-10-12 05:38   

Linux Change Run Level Command

Use the init command to change rune levels:
# init 1

Runlevel And Its Usage

The Init is the parent of all processes with PID # 1. Its primary purpose is to create processes from a script stored in the file /etc/inittab file. This file usually has entries which cause init to spawn gettys on each line that users can log in. A runlevel is nothing but a software configuration of the Linux system which allows only a selected group of processes to exist. The processes spawned by init for each of these runlevels are defined in the /etc/inittab file. Init can be in one of eight runlevels as follows:

  • Runlevel 0 is halt
  • Runlevel 1 is single-user
  • Runlevels 2-5 are multi-user (some distro uses RUN level 5 to start X [KDE/Gnome])
  • Runlevel 6 is for rebooting system

For example, typing the init 3 command will move system to run level 3:

# init 3

On most Linux server system default run level is 3 and on most Linux Desktop system default run level is 5. The default run level is defined by the initdefault line at the top of /etc/inittab file under CentOS / Fedora / Redhat / RHEL / Debian Linux. To change the default run level, edit /etc/inittab file, and edit entry initdefault:

# vi /etc/inittab

Set initdefault to 5, so that you can boot to X next time when Linux comes up:


Save and close the file. Reboot the system to see changes:
# reboot

More About getty

getty is the program which opens a tty port, prompts for a login name and password (via /bin/login command). Your console displays a login/password prompt at run levels 1 through 6. You can use ALT+F1...ALT+F6 keys to switch console (use CTRL+ALT+F1..F6 under X windows).

SSH logins are handled by OenSSH (sshd) server which starts at run level 2/3. KDE/Genome Desktop login are handled by GDM/XDM/KDM display manager which starts at run level 5 (however Debian Linux and some other distro can start them from run level 2 via special rc.d script located in /etc/init.d/gdm)

Related articles:

Updated for accuracy!

TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!

{ 12 comments… read them below or add one }

1 matt October 17, 2005 at 2:38 pm

you have some good content! i’m reading this blog since last 4+ months; althoug it is not updated daily like other blog/sites still it makes a good read as it is based upon Linux/UNIX sys admins hard core experince
considering only 1 or 2 perople contributes to this blog it is a good read and you have Good number of hits as well. Just wanna say good job man & keep it up


2 Anonymous October 17, 2005 at 2:44 pm

my questions is very simple how do i find out current runlevel as well as last runlevel? since you take linux sys admin class you must have some info :D



3 Namdev October 27, 2012 at 12:02 pm

0 – halt (shutdown pc)
1 – Single user mode
2 – Multiuser
3 – Full multiuser mode
4 – unused
5 – X11 (Graphical)
6 – reboot


# cat /etc/inittab

# vi /etc/inittab

To check Current Run Level
# who -r or
# runlevel

To change Run Level
# init 1

On most Linux server system default run level is 3 and on most Linux Desktop system default run level is 5.


4 narendra April 30, 2013 at 5:57 am

if it is set as 0, then how to change as system get reboot again and again
kindly advice


5 cyberciti October 17, 2005 at 6:31 pm

> how do i find out current runlevel as well as last runlevel?
Use who -r command
$ who -r
run-level 2 Oct 17 18:21 last=S


6 Ronald Kaiser April 9, 2012 at 2:24 pm

In order to get the last runlevel as well as the current, you can use /sbin/runlevel too.
$ /sbin/runlevel
S 2


7 cyberciti October 17, 2005 at 6:34 pm

Thanks matt :) We don’t update our blog everyday, as and when event occurs in our life it is get documented here.

I appreciate your post.


8 srikar March 5, 2013 at 9:55 am

 How to Change the run levels of the linux at run time with out restarting the system


9 Tony S. May 20, 2013 at 11:52 am

Thanks, this really helped me out. It turns out Ubuntu does have both commands, albeit a bit useless due to it lacking a proper single-user bootmode that’s accessible, this still helped. Thanks very much.


10 Rajesh May 20, 2013 at 2:04 pm

I went and changed the default run level as 6 in the config files. now system starts with default mode as 6 and then restarts again.


11 Guignol June 13, 2013 at 6:21 pm

For the folks fool enough to edit their /etc/inittab config file to 0 or 6, your only way to break the loop is to boot the system from a livecd, then navigate to the config file through the live filesystem (probably /mnt/sd*/etc/inittab or /media/*) and edit it. But seriously, what were you expecting to happen?


12 air805ronin January 8, 2014 at 11:01 pm

Guignol is actually kind of wrong there. A better option, to me, would to use Grub to boot into a specific runlevel, and then edit the inittab file to fix your mistake.

Just google “grub change runlevel” and you should get some useful results.


Leave a Comment

Tagged as: , , , , , , , , , , , , , , , ,

Previous post:

Next post: