Linux system repair mode (single user mode)

Linux system repair mode (single user mode)

Preface

There are two repair modes in Linux system, one is single-user mode and the other is CD repair mode.

The single-user mode of the Linux system is somewhat similar to the safe mode of the Windows system, which only starts the minimum number of programs for system repair. In single-user mode (runlevel 1), Linux boots into a root shell, with networking disabled and only a few processes running. Single-user mode can be used to repair file system damage, restore configuration files, move user data, etc.

illustrate:

The content that can be repaired in single-user mode is relatively simple, and in actual work it is mainly used to crack Linux passwords. If you forget your Linux password, you can use single-user mode to easily crack the system password.

1. Common bug fixes in single-user mode

The following errors can mainly be fixed in single-user mode:

Forgetting the root password is the most common mistake made by administrators. It can be fixed by using single-user mode. The biggest feature of entering single-user mode is that you can log in without entering a username and password.
Log in to the system through single-user mode and set a new password for the root user.
Execute the command: [root@localhost /]# passwd root

Modify the system default run level If we modify the system default run level incorrectly, such as changing it to 0 or 6, the system will not be able to start normally. You can also use single-user mode to repair it at this time.
After logging into the system in single-user mode, just modify the default run level configuration file /etc/inittab to change the system default run level back.
Execute the command:
[root@localhost /]# vi/etc/inittab
id:3:initdefault:
Change the default run level to 3 or 5. Note that the system's default run level can only be 3 or 5.

2. Modify the system password through single-user mode

(1) Enter the grub boot program

When starting the system, when the user counts down, press the enter key to enter the grub boot program we mentioned earlier.

The interface is as follows:

As shown in the figure below, press e key to enter the edit mode and edit the contents of the grub configuration file.

(2) Edit the corresponding system startup content

Press e key to edit the corresponding system startup content.

Select the system we need to modify and highlight it. We only have one system now, so just press e key. You can see three attributes in the editable grub configuration file.

As shown in the following figure:

(3) Edit the grub configuration file content

kernel properties are loading options for the Linux kernel. Select kernel properties to highlight them, and then press e key in this state to edit the contents of kernel properties.

As shown in the following figure:

After the default quiet , enter空格1 This space must be entered. If you do not enter the space, the final word will be quiet1 . quiet1 is an incorrect word and the system cannot recognize it and cannot run normally. The 1 entered here indicates the system operation level, and level 1 is single-user mode.

As shown in the following figure:

That is to tell the system to enter single-user mode when the kernel starts.

At this point, the above operations are to configure the login into single-user mode.

Then press enter key to return, as shown below:

Notice:

In this state, we cannot shut down and restart. The content of the grub configuration file we modify now is temporary. If we shut down or restart, our changes will disappear. To make it permanent, you need to modify the content of the grub configuration file /etc/inittab . You can see the prompt above, just press the b key to start the system.

(4) Start the system

Press the b key to start the system. The startup interface is as follows:

You can see that we logged into the system without entering a username and password.

(5) Change the root user's password

Now we can directly execute the command to change the password of the root user.

As shown in the following figure:

(6) Restart the system

Execute the reboot command to restart the Linux system normally.

Because the changes we made to the grub configuration file above are temporary, the previous changes will become invalid after the reboot. We can log in to the system directly with the root user and the new password just modified.

(7) Special attention

When we directly enter the init 1 command in the command line, the user mode we enter is different from the single-user (repair) mode we are talking about now. The reason why we enter the single-user (repair) mode is that there is a problem with the system, such as the most common problem of forgetting the system password. At this time, you cannot log in to the Linux system, so you cannot execute init 1 command.

If I can log into the Linux system, I can directly change the user password without having to enter the single-user mode to repair it. So the single-user recovery mode we are talking about here is not the single-user mode that can be entered by executing init 1 command in the system.

This is the end of this article about the repair mode (single-user mode) of the Linux system. For more relevant content about the Linux repair mode, please search for previous articles on 123WORDPRESS.COM or continue to browse the related articles below. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Steps to repair grub.cfg file corruption in Linux system
  • Historical Linux image processing and repair solutions
  • Linux users should pay attention to fix the vulnerability

<<:  CnBlogs custom blog style sharing

>>:  HTML table mouse drag sorting function

Recommend

The best 9 foreign free picture material websites

It is difficult to find good image material websi...

Detailed examples of using JavaScript event delegation (proxy)

Table of contents Introduction Example: Event del...

How to use Greek letters in HTML pages

Greek letters are a very commonly used series of ...

Detailed explanation of Nginx version smooth upgrade solution

Table of contents background: Nginx smooth upgrad...

JavaScript flow control (loop)

Table of contents 1. for loop 2. Double for loop ...

Native js implementation of slider interval component

This article example shares the specific code of ...

Detailed explanation of Nginx static file service configuration and optimization

Root directory and index file The root directive ...

MySQL table return causes index invalidation case explanation

Introduction When the MySQL InnoDB engine queries...

33 of the best free English fonts shared

ChunkFive Free Typefamily Cuprum JAH I Free font Y...

Linux virtual memory settings tutorial and practice

What is Virtual Memory? First, I will directly qu...

Detailed explanation of the usage of the ESCAPE keyword in MySQL

MySQL escape Escape means the original semantics ...

Example code for implementing stacked carousel effect with HTML+CSS+JS

Effect: When the slideshow moves in one direction...