The runlevel Command

The runlevel command is used to find the current and previous runlevels on Unix-like operating systems.

A runlevel is a preset operating state into which a system can be booted (i.e., started up). Each runlevel designates a different system configuration and allows access to a different combination of processes (i.e., instances of executing programs).

Seven runlevels are supported in the standard Linux kernel (i.e., core of the operating system), from 0, which halts the system, through 6, which reboots the system. Ordinary users are usually in runlevel 5 most of the time, which runs all typical system services including a GUI (graphical user interface). Runlevel 3 is similar except for the absence of a GUI; that is, it is command line (i.e., all-text mode) only. Runlevel 1 is single user mode, which is used for making system repairs. Runlevels 2 and 4 are intended for advanced users to configure as desired.

The syntax for the runlevel command is

runlevel [utmp]

runlevel is unusual in that it has no options and is usually used without an argument (i.e., input file), i.e.,


The runlevel executable (i.e., ready-to-run program) resides in the /sbin directory, which means that ordinary users will generally either have to first change to that directory using the cd (i.e., change directory) command or provide its absolute path (i.e., its full hierarchy of directories from the root directory) by appending /sbin to the beginning of the command, i.e.,


runlevel reads the utmp (an abbreviation of user's temporary) file and then writes the previous and current runlevels, separated by a single space, to standard output (which is the display screen by default). If there is no previous system runlevel (or if it cannot be determined), the letter N will be returned instead.

runlevel assumes that utmp is located in the /var/run/ directory. In the event that it is in a different location, its absolute path can be provided as an argument. If no utmp file exists, or if no runlevel record can be found, runlevel returns the word unknown and exits with an error message.

Another way to find the current and previous runlevels is to use the who command with its -r option, i.e.,

who -r

Created July 14, 2005.
Copyright © 2005 The Linux Information Project. All Rights Reserved.