Signup/Sign In

Use init command to change runlevel in Linux

Today, this article will introduce you to the very fundamental command in Linux, the init command, it is crucial for the proper operation of the system. It is essential for every single thing happen in Linux. The init command is the first process that is started when a Linux system boots up. It is responsible for starting all other processes and services that are necessary for the system to function properly.

How the init command works?

The init command is executed by the Linux kernel as the first process with a process ID (PID) of 1. It is responsible for starting all other processes and services that are required for the system to function properly. The init command reads a configuration file, called the "inittab" file, which specifies the processes and services that should be started at boot time.

The init command also controls the runlevels of the system. A runlevel is a predefined state of the system that specifies which processes and services should be running. The init command can switch between different runlevels, allowing the system administrator to control which processes and services are running on the system which makes the init command super useful while troubleshooting.

Linux init command help menu in gnome-terminal

Examples of Using the init Command

There are several common use cases for the init command. Here are a few examples:

  • Switching to a different runlevel: The init command can be used to switch between different runlevels using the following syntax:
$ init [runlevel]

For example, to switch to runlevel 3, you can use the following command:

$ init 3
  • Rebooting the system: The init command can be used to reboot the system using the following syntax:
$ init 6

This will shut down all processes and services, and then restart the system.

  • Shutting down the system: The init command can be used to shut down the system using the following syntax:
$ init 0

This will shut down all processes and services, and then power off the system.

Conclusion

The init command is a vital part of the Linux operating system, responsible for starting all other processes and services that are necessary for the system to function properly. It can be used to switch between different runlevels, reboot the system, and shut down the system. Understanding how the init command works and how to use it can be useful for system administrators and users who need to manage and control their Linux systems.



About the author:
Pradeep has expertise in Linux, Go, Nginx, Apache, CyberSecurity, AppSec and various other technical areas. He has contributed to numerous publications and websites, providing his readers with insightful and informative content.