TrumanWong

telinit

Switch the run level of the currently running system

Supplementary instructions

telinit command is used to switch the running level of the currently running Linux system.

The RUNLEVEL parameter should be one of the multi-user runlevels 2-5, 0 to stop the system, 6 to restart the system, or 1 to put the system into single-user mode.

Typically you would use the shutdown(8) tool to stop or restart the system, or lower it to single-user mode.

RUNLEVEL may also be S or s , which puts the system directly into single-user mode without actually stopping the process first, which you probably don't want.

Change the run level by emitting a runlevel(7) event, which includes the new run level in the RUNLEVEL environment variable and the previous run level in the PREVLEVEL variable (obtained from the environment or /var/run/utmp).

telinit will write the new runlevel to /var/run/utmp and append the new entry to /var/log/wtmp.

grammar

telint(option)(parameter)
telinit [OPTION]... RUNLEVEL

Options

-t: Specifies the number of seconds to wait.
-e key=value

This specifies additional environment variables to be included in the event along with RUNLEVEL and PREVLEVEL.

Parameters

Runlevel: Specify the runlevel to switch.

Environment

RUNLEVEL

If set to take precedence over reading from /var/run/utmp, telinit will read the current runlevel from this environment variable

Files

  • /var/run/utmp From where the current runlevel will be read; this file will also be updated with the new runlevel.
  • /var/log/wtmp New runlevel records will be appended to this file for the new runlevel.