Home > Package & System Management > init

init: System Initialization and Process Management

init is the first process executed (PID 1) in traditional Unix and Linux systems, acting as the parent process that manages all other system processes. It is responsible for system startup (booting) and shutdown, and controls the system's operating mode through runlevels. In modern Linux distributions, it is being replaced by systemd.

Overview

init, short for "initialization", is the first user-space process executed after the kernel is loaded into memory during system boot. The init process becomes the parent of all other processes and manages the overall state of the system. init uses the concept of runlevels to define and manage various system modes. While systemd largely replaces this role in modern Linux systems, the init command is still maintained for systemd compatibility.

Key Features

The key features of the init command are as follows:

  • Always has a PID (Process ID) of 1.
  • Acts as the parent of all processes.
  • Responsible for system booting and shutdown.
  • Controls system operating modes through runlevels.

Runlevel Description

init uses runlevels to specify the operating mode of the system. Each runlevel represents a specific state of the system.

  • 0: System halt mode. Stops all processes and powers off the system.
  • 1: Single User mode. Used for system maintenance or recovery, with networking and other services disabled.
  • 2: Multi-user mode without Network File System (NFS).
  • 3: Multi-user mode with all services started, in a text-based environment. Primarily used in server environments.
  • 5: Multi-user mode including a graphical environment, typical for desktop environments.
  • 6: System reboot mode.

Main Options

The init command is primarily used by specifying a runlevel as a numeric argument. It uses numbers as arguments rather than direct options.

1) Change Runlevel

Generated command:

Try combining the commands.

Description:

`init` Executes the command.

Combine the above options to virtually execute commands with AI.

Usage Examples

Learn the functionalities of the init command through various usage examples.

System Shutdown

sudo init 0

Safely shuts down the system. This has a similar effect to 'shutdown -h now'.

Switch to Single User Mode

sudo init 1

Switches to single user mode for file system recovery or system inspection.

System Reboot

sudo init 6

Reboots the system. This has a similar effect to the 'reboot' command.

Tips & Precautions

Here are some points to consider when using the init command.

Tips

  • The init command requires root privileges, so it must be used with 'sudo'.
  • Using the init command has an immediate impact on the system, so it should be used carefully in an environment where no other users are present.
  • In modern Linux systems (e.g., Ubuntu, CentOS), systemd is the standard instead of init, so using 'shutdown', 'reboot', or 'systemctl' commands is recommended.
  • Runlevels are typically defined in the /etc/inittab file, but this file is not used in systems that use systemd.

Related commands

These are commands that are functionally similar or are commonly used together.


Same category commands