TrumanWong

runlevel

Print the running level of the current Linux system

Supplementary instructions

runlevel command is used to print the running level of the current Linux system.

grammar

runlevel

Knowledge expansion

The Linux operating system needs to go through several different stages from startup to completion. These stages are called runlevels. Similarly, when the Linux operating system is shut down, it also goes through several different runlevels. We are going to introduce them in detail below. runlevel and show you some tips to avoid unnecessary reboots of your Linux system.

Runlevel can be thought of as the system status. To put it more graphically, you can think of runlevel as a bit like Normal, safemode, and command prompt only in Microsoft's Windows operating system. Entering each runlevel requires starting or shutting down a corresponding series of services. These services are placed in the directory /etc/rc.d/rc?.d/ or /etc/ in the form of initialization scripts. rc?.d below (? represents the corresponding sequence number of runlevel).

In most Linux distributions, there are usually 8 runlevels:

0 downtime
1 Single user mode
2 multi-user, no NFS
3 Full multi-user mode
4 not used
5 Graphical interface
6 Restart
S s Single user mode

The default runlevel of most desktop Linux systems is 5, which is a graphical interface when users log in, while the default runlevel of most server versions of Linux systems is 3, which is a character interface when users log in. Runlevels 1 and 2 are except for debugging. Rarely used, runlevel s and S are not directly used by users, but are used to prepare for Single user mode.

The advantage of the Linux running mode compared to the Windows startup mode is that you can use the init command to switch the runlevel you are currently using when the system is idle. In addition, when you shut down or start the Linux system, you have switched your runlevel unknowingly. , the system shutdown process needs to call runlevel (0 or 6) to shut down all running processes.