runlevel – report previous and current Unix OS runlevel

runlevel is a basic Unix command aimed to do one simple task: report the runlevel of your Unix OS.

How runlevel command works

Your Unix system carefully logs information about every login session in special files. /var/run/utmp is the file containing information about everyone who's currently logged in, and since every record contains a runlevel information, it makes sense to use this file as a proof of the current OS runlevel.

runlevel command reads /var/run/utmp file and extracts the most recent login entry. It then uses this entry to extract the current and previous runlevel information from it.

Using runlevel command

Simply run the command without any parameters:

redhat$ runlevel
N 5

As it was said earlier, the two numbers shown are supposed to be previous and current Unix runlevels.

However, the previous runlevel information is not usually found in the most recent login entry simply because runlevel hasn't changed,

so the command prints "N" instead of it.

Looking at the output above, you can see that the current runlevel is 5.

See also:

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS