runlevel Command in Linux

This tutorial explains Linux “runlevel” command, options and its usage with examples.

runlevel — find the current and previous system runlevel.

DESCRIPTION

Runlevel 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.

If no utmp file exists, or if no runlevel record can be found, runlevel prints the word unknown and exits with an error.

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

advertisement
advertisement

The utmp file allows one to discover information about who is currently using the system. There may be more users currently using the system, because not all programs use utmp logging.

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

SYNOPSIS

runlevel [utmp]

OPTION

utmp
The name of the utmp file to read.

EXAMPLE

advertisement

1. Simple Example

$ runlevel
N 2

Runlevel 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 screen.

Sanfoundry Global Education & Learning Series – 1000 Linux Tutorials.

advertisement
If you wish to look at all Linux commands and their usage examples, go to Linux Commands Tutorial.

If you find any mistake above, kindly email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.