RUNLEVEL(8)

๐Ÿ’– RUNLEVEL(8) ๐Ÿ’–

okay bestie, welcome to runlevel โ€” the little tool that prints your previous and current SysV runlevel. it lives in the systemd family (runlevel(8)), and yes, we're gonna get into why this is a bit of a legacy vibe. buckle up ๐ŸŽ€


โœจ SYNOPSIS โœจ

runlevel [options...]

๐ŸŒธ OVERVIEW ๐ŸŒธ

so. "Runlevels" are an obsolete way to start and stop groups of services, used back in the day by SysV init. systemd ships a compatibility layer that maps runlevels onto targets, plus the associated binaries like runlevel. lowkey iconic of it to keep the lights on.

but here's the thing, bestie โ€” only one runlevel can be "active" at any given time, while systemd can activate multiple targets concurrently. so the mapping to runlevels is confusing and only approximate. it's giving โœจvibes-based translationโœจ

runlevels should not be used in new code. their main character moment is basically as a shorthand way to refer to the matching systemd targets in kernel boot parameters. that's it. that's the job. periodt.

Table 1. Mapping between runlevels and systemd targets (no table, just a slay little list, iykyk)

  • runlevel 0 โ†’ poweroff.target
  • runlevel 1 โ†’ rescue.target
  • runlevel 2, 3, 4 โ†’ multi-user.target
  • runlevel 5 โ†’ graphical.target
  • runlevel 6 โ†’ reboot.target

๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

runlevel prints the previous and current SysV runlevel, if they are known. if they're known, bestie. IF. ๐Ÿ˜ญ

the two runlevel characters are separated by a single space character. cute, minimal, no notes.

if a runlevel can't be determined, N is printed instead. and if neither can be determined? it just prints the word unknown. very honest of it honestly.

unless it's overridden in the environment, this will check the utmp database for recent runlevel changes.


๐Ÿ’… OPTIONS ๐Ÿ’…

the following option is understood (just the one, and she ate):

  • --help โ€” print a short help text and exit. that's it, that's the whole option menu. short king ๐Ÿ‘‘

โญ EXIT STATUS โญ

if one or both runlevels could be determined, 0 is returned. otherwise you get a non-zero failure code. no in-between, no nuance, just binary slay ๐Ÿ’€


๐Ÿ“ ENVIRONMENT ๐Ÿ“

  • $RUNLEVEL โ€” if $RUNLEVEL is set, runlevel will print this value as the current runlevel and ignore utmp. it's taking the override, no cap.
  • $PREVLEVEL โ€” if $PREVLEVEL is set, runlevel will print this value as the previous runlevel and ignore utmp. same energy, different variable ๐Ÿซถ

๐ŸŒˆ FILES ๐ŸŒˆ

  • /run/utmp โ€” the utmp database that runlevel reads the previous and current runlevel from.
added in version 237. a whole era. ๐Ÿ’œ

๐Ÿงš SEE ALSO ๐Ÿงš

systemd(1), systemd.target(5), systemctl(1)

go read those next bestie, they're the real main characters of this story โœจ


and that's the whole page, babes โ€” this lil manual came to you courtesy of systemd 257.13, the RUNLEVEL(8) page. stay slaying, stay mapped to the right target, and please don't write new code with runlevels. mwah ๐Ÿ’–๐ŸŽ€๐Ÿฆ‹

๐Ÿ“ฆ where this page comes from