Determining Your System’s Runlevel

From time to time, you might be unsure just what runlevel your system is in. For example, you may have logged into a Linux system from a remote location and not know how it was booted or maintained. You may also need to know what runlevel your system was in prior to its current runlevel—perhaps wondering if the system was last in single-user mode for maintenance.

To determine this information, use the runlevel command. It displays the previous and current runlevel as integers, separated by a space, on standard output. If no runlevel change has occurred since the system was booted, the previous runlevel is displayed as the letter N. For a system that was in runlevel 3 and is now in runlevel 5, the output is:

# runlevel
3 5

For a system with a default runlevel of 5 that has just completed booting, the output would be:

# runlevel
N 5

runlevel does not alter the system runlevel. To do this, use the init command (or the historical alias telinit).

Get LPI Linux Certification in a Nutshell, 3rd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.