telinit
The telinit
command is used to change the runlevel of a system in Unix-like operating systems that use the SysVinit init system. Runlevels are preset operating states that define what system services are available. Each runlevel has its own configuration and purpose.
Overview of Runlevels
0: Halt the system
1: Single-user mode (maintenance or emergency mode)
2: Multi-user mode without networking (varies by distribution)
3: Multi-user mode with networking (text mode)
4: Undefined (can be user-defined)
5: Multi-user mode with networking and graphical interface (default for many distributions)
6: Reboot the system
Usage of telinit
telinit
The telinit
command is a symbolic link to the init
command. It sends signals to the init
process to change the system runlevel. When you use telinit
, you are essentially instructing the init
process to transition the system to a specified runlevel.
Basic Syntax
Example Commands
Changing to Runlevel 1 (Single-User Mode)
Single-user mode is typically used for maintenance purposes, where you need minimal services running:
Changing to Runlevel 3 (Multi-User Mode without GUI)
Runlevel 3 is used for full multi-user mode with networking but without a graphical interface:
Changing to Runlevel 5 (Multi-User Mode with GUI)
Runlevel 5 is used for full multi-user mode with networking and a graphical user interface:
Rebooting the System (Runlevel 6)
To reboot the system:
Halting the System (Runlevel 0)
To halt the system:
Checking Current Runlevel
To check the current runlevel of the system, use the runlevel
command:
This command outputs two characters: the previous and the current runlevel. For example:
This means there was no previous runlevel (N
) and the current runlevel is 5.
Transitioning from SysVinit to Systemd
In systems using systemd
, the concept of runlevels is replaced by targets, which offer more flexibility. However, systemd
maintains compatibility with traditional runlevels.
Equivalent Commands in systemd
systemd
To change the runlevel (target) in systemd
, use the systemctl isolate
command:
Single-User Mode (rescue.target):
Multi-User Mode without GUI (multi-user.target):
Multi-User Mode with GUI (graphical.target):
Reboot the System:
Halt the System:
Conclusion
The telinit
command is an essential tool for managing the runlevel of a Unix-like system using SysVinit. Understanding how to change runlevels is crucial for system maintenance and administration. With the transition to systemd
, similar functionalities are maintained through targets, providing a more modern and flexible approach to system state management.
Last updated