Linux define the runlevel and determine which runlevel my system is currently in

Q. How to define the Linux system runlevel and how do I determine which runlevel my system is currently in?

ADVERTISEMENTS

A. You need to use runlevel command to find the current and previous system runlevel. Usaully 0-6 runlevel are used by all Linux distributions:

=> 0 : Halt system

=> 1 : Take system to single-user mode (good for Linux system maintenance)

=> 2 : User defined or distribution like Debian use it

=> 3 : Full multi-user mode (text mode login)

=> 4 : Not used/user-defined

=> 5 : Full multi-user GUI mode login

=> 6 : Reboot system

Please note that runlevels 0, 1, and 6 are reserved. Runlevel 0 is used to halt the system, runlevel 6 is used to reboot the system, and runlevel 1 is used to get the system down into single user mode.

Task: Determine which runlevel my system is currently in

Type runlevel command:
$ runlevel

Output:

N 3

runlevel command reads the system utmp file (typically /var/run/utmp) to locate the runlevel record, and then prints the previous and current system runlevel on its standard output, separated by a single space. If there is no previous system runlevel, the letter N will be printed instead.

Task: Change runlevel

Use init command to change the runlevel. For example runlevel 1 is used to get the system down into single user mode:
# init 1

🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
FirewallCentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNCentOS 8 Debian 10 Firewall Ubuntu 20.04

ADVERTISEMENTS
6 comments… add one
  • sheik Aug 31, 2010 @ 19:07

    how to increase or add run level on rhel . . .
    psl help me . .

    • linux torvalds Oct 16, 2013 @ 13:57

      no you cannot increase runlevels !
      but you can define new runlevel by using ‘runlevel 4′ which is provided for users to create their own user-defined runlevel !
      these above lines are true for general linux system ! to know about your operating system goto :
      http://en.wikipedia.org/wiki/Runlevel#Red_Hat_Linux_and_Fedora

  • Paulomjeet Apr 30, 2011 @ 1:15

    Can you increase runlevels in linux? If you increase run levels how to increase?

    • linux torvalds Oct 16, 2013 @ 13:56

      no you cannot increase runlevels !
      but you can define new runlevel by using ‘runlevel 4’ which is provided for users to create their own user-defined runlevel !
      these above lines are true for general linux system ! to know about your operating system goto :http://en.wikipedia.org/wiki/Runlevel

  • eswarreddy Mar 19, 2012 @ 18:07

    i want only previous runlevel and current runlevel individually
    ex:
    runlevel
    3 5
    3 =present
    5=previous.
    i want inly one runlevel
    help me……………………………………

    • Friedemann Reiche Feb 8, 2015 @ 11:52

      Just in case anyone is still wondering how to do this:
      runlevel | sed -e “s:..::”

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.