Find out runlevel of unix or Linux system

Home » Questions» Linux

Subscribe

Subscribe to mail newsletter

How do I find out runlevel of unix or Linux system?

A runlevel is a software configuration of the system which allows only a selected group of processes to exist. The processes spawned by init command/process for each of these runlevels are defined in the /etc/inittab file. Runlevels 0, 1, and 6 are reserved. Runlevel 0 is used to halt the sys tem, runlevel 6 is used to reboot the system, and runlevel 1 is used to get the system down into single user mode. In order to print current runlevel you need to use command who or runlevel as follows:

1) Print print current runlevel using who command:

$ who -r

run-level 2  Dec 16 11:45                   last=S
2) Find the current and previous system runlevel using runlevel command:

$ 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. Runlevel can be used in rc scripts as a substitute for the System-V who -r command. However, in newer versions of init this information is also available in the environment variables RUNLEVEL and PREVLEVEL:

$ echo $RUNLEVEL
$ echo $PREVLEVEL

Related articles

Tips & Tricks | Email