Thanks to visit codestin.com
Credit goes to man.x-cmd.com

Skip to content

runlevel

runlevel [utmp]

Find the current and previous system runlevel

If no utmp file exists or if no runlevel record can be found, print "unknown"