Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

runlevel(8) [linux man page]

runlevel(8)						      System Manager's Manual						       runlevel(8)

NAME
runlevel - output previous and current runlevel SYNOPSIS
runlevel [OPTION]... [UTMP] DESCRIPTION
runlevel reads the system UTMP file, which defaults to /var/run/utmp when no alternate filename is given, to locate the most recent run- level record. The previous and current runlevel from that record are output separated by a single space. If there is no previous runlevel in the record, the letter N will be substituted. If no runlevel record can be found, runlevel outputs the word unknown and exits with an error. During system boot, the environment variables RUNLEVEL and PREVLEVEL will be set by the init(8) daemon, these come from the runlevel(7) event generated by telinit(8) or shutdown(8). When these environment variables are set, runlevel will output the values from these instead. Thus runlevel can be used in rc scripts as a replacement for the System-V who(1) -r command. OPTIONS
--quiet Does not output the current and previous runlevel, nor does it output unknown in the case of error (but it will exit with an error code). This may be used to test for the presence of a runlevel entry, or to check for errors reading from the file. EXIT STATUS
runlevel will exit with status 0 if a UTMP record was found, otherwise it will exit with status 1. ENVIRONMENT
RUNLEVEL runlevel will read the current runlevel from this environment variable if set in preference to reading from /var/run/utmp PREVLEVEL runlevel will read the previous runlevel from this environment variable if RUNLEVEL was given, in preference to reading from /var/run/utmp FILES
/var/run/utmp Where the current and previous runlevels will be read from. NOTES
The Upstart init(8) daemon does not keep track of runlevels itself, instead they are implemented entirely by its userspace tools. A change of runlevel is signalled by the runlevel(7) event, generated by either the telinit(8) or shutdown(8) tools. This event includes the new runlevel in the RUNLEVEL environment variable, as well as the previous runlevel (obtained from their own environment or from /var/run/utmp) in the PREVLEVEL variable. As well as generating the event, both tools write the new runlevel back to /var/run/utmp and append a new entry to /var/log/wtmp. AUTHOR
Written by Scott James Remnant <scott@netsplit.com> REPORTING BUGS
Report bugs at <https://launchpad.net/upstart/+bugs> COPYRIGHT
Copyright (C) 2009 Canonical Ltd. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICU- LAR PURPOSE. SEE ALSO
runlevel(7) init(8) telinit(8) shutdown(8) who(1) Upstart 2009-07-09 runlevel(8)

Check Out this Related Man Page

telinit(8)						      System Manager's Manual							telinit(8)

NAME
telinit - change system runlevel SYNOPSIS
telinit [OPTION]... RUNLEVEL DESCRIPTION
telinit may be used to change the system runlevel. The RUNLEVEL argument should be one of the multi-user runlevels 2-5, 0 to halt the system, 6 to reboot the system or 1 to bring the system down into single-user mode. Normally you would use the shutdown(8) tool to halt or reboot the system, or to bring it down to single-user mode. RUNLEVEL may also be S or s which will place the system directly into single-user mode without actually stopping processes first, you prob- ably won't want that. The runlevel is changed by emitting the runlevel(7) event, which includes the new runlevel in the RUNLEVEL environment variable as well as the previous runlevel (obtained from the environment or from /var/run/utmp) in the PREVLEVEL variable. telinit will write the new runlevel to /var/run/utmp and append a new entry to /var/log/wtmp. Other commands telinit may be also used to send basic commands to the init(8) daemon for compatibility with System V. These are: Q or q to request that init(8) reload its configuration. This is rarely necessary since Upstart watches its configuration with inotify(7) and is deprecated by the initctl(8) reload-configuration command. U or u to request that the init(8) daemon re-execute itself. This is not recommended since Upstart is currently unable to preserve its state, but is necessary when upgrading system libraries. OPTIONS
-e KEY=VALUE This specifies an additional environment variable to be included in the event along with RUNLEVEL and PREVLEVEL. ENVIRONMENT
RUNLEVEL telinit will read the current runlevel from this environment variable if set in preference to reading from /var/run/utmp FILES
/var/run/utmp Where the current runlevel will be read from; this file will also be updated with the new runlevel. /var/log/wtmp A new runlevel record will be appended to this file for the new runlevel. NOTES
The Upstart init(8) daemon does not keep track of runlevels itself, instead they are implemented entirely by its userspace tools. See runlevel(7) for more details. AUTHOR
Written by Scott James Remnant <scott@netsplit.com> REPORTING BUGS
Report bugs at <https://launchpad.net/upstart/+bugs> COPYRIGHT
Copyright (C) 2009 Canonical Ltd. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICU- LAR PURPOSE. SEE ALSO
runlevel(7) init(8) initctl(8) shutdown(8) runlevel(8) Upstart 2009-07-09 telinit(8)
Man Page