telinit is a command-line tool used to change the runlevel of a SysVinit-based Linux system. A runlevel is a state in which the system is configured to run a specific set of services, daemons, and applications. For example, runlevel 3 is typically used for a text-based console, while runlevel 5 is used for a graphical desktop environment.
In traditional SysVinit systems, changing the runlevel involves executing the telinit command with a specific runlevel number (e.g., telinit 3 to switch to runlevel 3). telinit sends a signal to the init process, which then stops or starts services and daemons according to the new runlevel.
However, the concept of SysV runlevels is considered obsolete in modern Linux distributions that use systemd as the init system. Systemd uses the concept of “targets” instead of runlevels, which are essentially equivalent to runlevels but with more features and flexibility. Therefore, when you use telinit to change the runlevel on a systemd-based system, the command will be transparently translated into a systemd unit activation request that corresponds to the equivalent target.
For example, if you run telinit 3 on a systemd-based system, the command will be translated into a request to activate the multi-user.target, which corresponds to runlevel 3 in SysVinit. Similarly, if you run telinit 5, the command will be translated into a request to activate the graphical.target, which corresponds to runlevel 5 in SysVinit.
telinit Command Examples
1. Power off the machine:
# telinit 0
2. Reboot the machine:
# telinit 6
3. Change SysV run level:
# telinit 2|3|4|5
4. Change to rescue mode:
# telinit 1
5. Reload daemon configuration:
# telinit q
6. Do not send a wall message before reboot/power-off (6/0):
# telinit --no-wall value
Summary
It is worth noting that the telinit command is still supported in modern Linux distributions for backward compatibility reasons. However, it is recommended to use the systemctl command instead to manage systemd targets and services. systemctl provides a more powerful and flexible interface for managing the system state, and it is the recommended way to manage services and daemons in modern Linux systems.