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

Advertisements