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 does CentOS7 reset the root password

2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article is about how CentOS7 resets root passwords. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

The miscellaneous environment and configuration problems in the process of moving bricks always encounter different mistakes every time. Google discovers at a glance that what others can solve may not be right for you. The circumstances in which I have encountered problems this time are:

Windows 10 Enterprise Edition 2016 LTS

VMware ®Workstation 14 Pro 14.1.0 build-7370693

CentOS Linux release 7.5.1804 (Core)

The CentOS 7 root password installed in VMWare has been forgotten and can only be reset

First, start the client

After entering the above interface, press e, and then enter the following interface

Second, modify the startup file

The cursor goes down to find the location of the Linux16,ro

Change ro to rw init=/sysroot/bin/sh and press Ctrl + x to restart.

Here to explain, some tutorials said to change to rw init=/bin/sh, anyway, I did not succeed! Restart the client after changing it to rw init=/bin/sh and report an error as follows

It is said that my BIOS crashes hw-PMU resources, and the client operating system has disabled CPU. Please shut down or reset the virtual machine. So I went to Google according to this error for a long time, saying that the Windows system did not turn on CPU virtualization, so I restarted the laptop and entered BIOS.

Found that Intel virtualization Technology is on, the problem is getting more and more outrageous, or change it to rw init=/sysroot/bin/sh!

III. Restart

After restarting the client, enter the following interface and execute chroot / sysroot

Execute passwd root to change root user password

: / # passwd rootChanging password for user rootNew password:Retype new password:passwd: Authentication token manipulation error

IV. Update / etc/shadow

If there is an error prompt Authentication token manipulation error, it means that the root password change failed. The correct answer is here. Because there is no / etc/shadow file, as shown in the figure

Only gshadow and gshadow-. Regenerate the shadow file through pwconv and set the permission to-rw-r-

5. Remount the root partition

Mount-o remount,rw /

Change the root password at this time and find that it is OK.

: / # passwd rootChanging password for user rootNew password:Retype new password:passwd: all authentication tokens updated successfully

Restart the client login successfully!

Thank you for reading! This is the end of the article on "how to reset the root password for CentOS7". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!

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