Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to parse the running level of Linux system

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

In this issue, Xiaobian will bring you about how to analyze the Linux system running level. The article is rich in content and analyzes and narrates from a professional perspective. After reading this article, I hope you can gain something.

inittab profile

There is an inittab file/etc/inittab in the configuration file directory that stores the runlevel of the system specifically, and this runlevel is queried when the Linux system boots.

From a large number of comments in the file, we know that this file is only used to set the system's operating level, which is divided into 7 operating levels:

0-halt(stop/shutdown)(do not set runlevel to 0)

1-Single User Mode

2-Multi-user mode, no network

3-Multi-user mode with network

4-unused (reserved)

5-Graphical interface

6-Restart (do not set runlevel to 6)

Common runlevels are 3 and 5, which was mentioned in the previous article. If you want to change the default initialization runlevel, just change the number after "id: ."

Switch operation level

In addition to modifying the default runlevel in the inittab file, administrators can switch between seven levels at will via the init command, notably levels 0 and 6, which are also equivalent to shutdown and reboot.

Case 1: Switch the run level to 3 and then to 5

Open the terminal and execute the init command:

Log back in as root to see the current operating level:

Switch back to Run Level 5 and view:

Case 2: Retrieving the root password

How do I recover the root password using the system runlevel?

*** Step: Start up, enter enter in the boot interface

Step 2: Enter e, edit the command before starting, move the cursor, select kernel, and then enter e

Step 3: Enter 1 at the end of the line, enter, set the run level to 1 (single user mode)

Step 4: Enter b to boot the system

Step 5: Change password

After the restart has entered the single-user mode, this is to arbitrarily modify the user password, not only root all user passwords can be modified.

Note: Single user mode does not require any password to log in. At this time, the operating level is 1. In this mode, there is no network connection, and the Linux administrator must directly operate on the physical machine, so the Linux system default operator is trusted.

Case 3: The default run level in the inittab file is 0 or 6, how to recover from ** shutdown and ** restart?

What if I accidentally set the system startup default runlevel to 0 or 6 while modifying the/etc/inittab file?

At this point, you can also modify the inittab file using single-user mode.

Similar to case 2, edit the command before the system starts, enter the single-user mode, directly modify the inittab file, and then restart it.

The above is how to analyze the Linux system running level shared by Xiaobian for everyone. If you happen to have similar doubts, you may wish to refer to the above analysis for understanding. If you want to know more about it, please pay attention to the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report