telinit

system administrationLinux/Unix
The telinit command is one of the most frequently used commands in Linux/Unix-like operating systems. telinit Change SysV init runlevel or systemd system state

Quick Reference

Command Name:

telinit

Category:

system administration

Platform:

Linux/Unix

Basic Usage:

telinit [options] [arguments]

Common Use Cases

    Syntax

    telinit [option] <runlevel>

    Options

    Option Description
    -t SEC, --timeout=SEC Set timeout for processes in seconds (SysVinit)
    -f, --force Force operation (SysVinit)
    -e, --evaluate Evaluate variables in /etc/inittab (SysVinit)
    -h, --help Display help and exit
    -V, --version Output version information and exit

    Common Runlevels:

    Runlevel Description
    0 Halt or shutdown the system
    1, s, S Single-user mode (for maintenance/recovery)
    2 Multi-user mode without networking (varies by distribution)
    3 Multi-user mode with networking (command line)
    4 User-definable (not commonly used)
    5 Multi-user mode with networking and GUI
    6 Reboot the system
    q, Q Reload init configuration

    Examples

    How to Use These Examples

    The examples below show common ways to use the telinit command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.

    # Basic Examples Basic
    # Change to runlevel 3 (multi-user mode without GUI) sudo telinit 3
    # Change to runlevel 5 (multi-user mode with GUI) sudo telinit 5
    # Change to single user mode (maintenance mode) sudo telinit 1
    # Shut down and power off the system sudo telinit 0
    # Reboot the system sudo telinit 6
    # Advanced Examples Advanced # Reload init configuration files without changing runlevel sudo telinit q # Force all processes to terminate and change to runlevel 1 sudo telinit -f 1 # In systems using systemd, change to multi-user.target (equivalent to runlevel 3) sudo telinit 3 # In systems using systemd, change to graphical.target (equivalent to runlevel 5) sudo telinit 5 # In systems using systemd, change to rescue.target (equivalent to runlevel 1) sudo telinit 1 # In systems using systemd, reboot the system sudo telinit 6 # In systems using systemd, power off the system sudo telinit 0 # Get the current runlevel (though 'who -r' or 'runlevel' is preferred) sudo telinit # Send a custom signal to the init process (SysVinit) sudo telinit u

    Try It Yourself

    Practice makes perfect! The best way to learn is by trying these examples on your own system with real files.

    Understanding Syntax

    Pay attention to the syntax coloring: commands, options, and file paths are highlighted differently.

    Notes

    The `telinit` command is used to change the system's runlevel or system state. It works by sending appropriate signals to the init process, which is the first process started during boot (PID 1) and the parent of all other processes. Historically, `telinit` was primarily associated with SysV init, the traditional init system used in many Unix and Linux distributions. In SysV init, the concept of runlevels defines different system states, each with its own set of services and processes. For example, runlevel 3 typically represents a multi-user, networked environment without a graphical interface, while runlevel 5 includes the graphical user interface. In modern Linux distributions that use systemd, `telinit` still exists but functions differently. Systemd doesn't use traditional runlevels but instead uses "targets" to define system states. However, for compatibility, `telinit` in systemd-based systems maps traditional runlevels to equivalent systemd targets: - Runlevel 0 → poweroff.target - Runlevel 1 → rescue.target - Runlevel 3 → multi-user.target - Runlevel 5 → graphical.target - Runlevel 6 → reboot.target The `telinit` command requires root privileges because changing the system's runlevel affects the entire system and can start or stop critical services. In addition to changing runlevels, `telinit q` (or `telinit Q`) is a special command that tells init to re-examine its configuration file (/etc/inittab in SysV init) without changing the current runlevel. This is useful after making changes to the configuration. It's worth noting that in systemd-based systems, the preferred commands for changing system states are `systemctl isolate [target]` for changing the current state and `systemctl set-default [target]` for setting the default state at boot. For example, `systemctl isolate multi-user.target` is equivalent to `telinit 3`. While `telinit` is still available in most distributions for compatibility reasons, system administrators working with modern systems should become familiar with the corresponding systemd commands for better integration with the current init system.

    Related Commands

    These commands are frequently used alongside telinit or serve similar purposes:

    Use Cases

    Learn By Doing

    The best way to learn Linux commands is by practicing. Try out these examples in your terminal to build muscle memory and understand how the telinit command works in different scenarios.

    $ telinit
    View All Commands