telinit Command in Linux



The telinit command in Linux changes the system run level. A run level is a number that tells a Unix-like system what state it should be in, what services to run, and which mode to operate in. Only one run level is active at a time.

On systems using systemd, telinit is often a symbolic link to systemctl, ensuring backward compatibility.

Table of Contents

Here is a comprehensive guide to the options available with the telinit command −

Note − telinit is an old command kept for compatibility. It is outdated and should not be used because run levels are no longer used in modern Linux systems.

Syntax of telinit Command

The syntax of the telinit command in Linux is as follows −

telinit [options...] {COMMAND}

In the above syntax, the [options...] are optional flags or arguments that can be included. The {COMMAND} is the required action, usually a run-level number.

telinit Command Options

The options of the Linux telinit command are listed below −

Option Description
--no-wall Do not send a wall message before power-off/reboot.
0 Power off the machine (systemctl poweroff).
6 Reboot the machine (systemctl reboot).
2, 3, 4, 5 Switch to specified SysV runlevel (systemctl isolate runlevelX.target).
1, s, S Enter rescue mode (systemctl rescue).
q, Q Reload the daemon configuration (systemctl daemon-reexec).
u, U Reexec daemon and restore state (systemctl daemon-reexec).
--help Show help text and exit.

Note − The run-level meanings may vary by distribution.

Examples of telinit Command in Linux

This section explains how to use the telinit command in Linux with examples −

  • Changing Run Level using telinit
  • Entering the Rescue Mode
  • Reloading the init Configuration
  • Restarting the init System
  • Displaying Usage Help

Changing Run Level using telinit

To change the run level, use the telinit command followed by the run level number with sudo privileges. For example, to reboot the system, use run level 6 −

sudo telinit 6

A list of other run levels with their operations is given below −

Run Level Description
0 Halt the system (power off)
1 Single-user mode (maintenance/rescue)
2 Multi-user mode (no network or GUI)
3 Multi-user mode with networking
4 Undefined / custom
5 Multi-user mode with GUI
6 Reboot the system
S/s Single-user mode (similar to runlevel 1)

Entering the Rescue Mode

Rescue mode is a minimal environment used to diagnose and fix system problems. To enter the rescue mode, use the s or S option −

sudo telinit s

Its equivalent in the modern systems is systemctl rescue.

Reloading the init Configuration

To reload the init configuration, which is equivalent to daemon configuration in modern Linux systems, use the q or Q option −

sudo telinit q

To verify whether the above command is successfully executed or not, check the exit status using the following command −

echo $?
telinit Command in Linux1

If it is 0, the command is executed without any error. Or, check the log using the following command −

journalctl -xe | grep daemon-reload
telinit Command in Linux2

The corresponding systemctl command is given below −

sudo systemctl daemon-reload

Restarting the init System

To safely restart the init system, such as sysV or systemd, use the u or U option with the telinit command −

sudo telinit u
telinit Command in Linux3

The systemctl equivalent command is as follows −

sudo systemctl daemon-reexec

Displaying Usage Help

To display the usage help of the telinit command, use the --help option −

telinit --help

Conclusion

The telinit command in Linux is used to change the system's run level, controlling which services are active and in which mode the system operates. Although still supported for compatibility, it is largely replaced by systemctl on modern systems.

This tutorial covered the syntax, options, and practical examples of using telinit, such as changing run levels, entering rescue mode, reloading configuration, and restarting the init system.

Advertisements