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

The solution of CentOS 7 forgetting root password

2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

What is the solution for CentOS 7 to forget the root password? In view of this problem, this article introduces the corresponding analysis and answers in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible way.

Many command tables: yes (reboot or int 6 Murray-use more. Or shutdown-r now)

Expansion: other things we usually use, such as [shutdown: int 0mu-shutdown or poweroff], just need to restart.

2. Select the E key to enter the grub interface.

When the two options appear, select the corresponding selection or E key to edit the startup item we selected.

The grub interface appears. This is to find the boot disk when your system starts, (it manages and loads the hard drive)

Cdn.sohucs.com/images/20180823/073e39af61b646f2ace9899376304eda.png ">

3. Change ro to rw;init=sysroot/bin/sh

Position the cursor at linux16, and then the right arrow key until ro changes this place to rw, which is read-only and now read-write.

4. To start (hold down CTRL+X)

This is the path where the original system is located: CTrl+X, come out an interface. We can now run some commands.

You can see there's nothing in it, ls / sysroot/boot/.

Because there is no mount, there is only a separate partition.

5. Switch to the original system for execution: chroot / sysroot/

The original system is under sysroot, how to change the password of the original system?

1. Switch to the original system environment. With command; chroot / sysroot/

6. Change the root password: passwd root

Small square that appears: defined as English: LANG=en

Execute: passwd root command, you can change the password.

For example, change to: password1234

7. Execute: touch / .autorelabel

After the change is completed, one more key operation, touch / .autorelabel, will be done.

Then restart the virtual machine.

Try logging in with your new password.

Or:

Finally, enter the command [touch / .autorelabel]

Create a .autorelabel file in the / directory, and if this file exists, the entire file system will be relabeling when the system restarts.

And the command [exit] to exit

And command [reboot] to restart.

The following system can log in.

This is the answer to the question about how CentOS 7 forgot the root password. I hope the above content can be of some help to you. If you still have a lot of doubts to solve, you can follow the industry information channel to learn more about it.

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

Servers

Wechat

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

12
Report