Get the App
SLTechnology News&Howtos  ›  Development  › 

How does CentOS7 reset the root password

Shulou Source: shulou.com Published: 2022-05-31 23:28:48 09月21日 Update

This article Xiaobian for you to introduce in detail "CentOS7 how to reset root password", the content is detailed, the steps are clear, the details are handled properly, I hope this "CentOS7 how to reset root password" article can help you solve your doubts, following the editor's ideas slowly in-depth, let's learn new knowledge.

Question:

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. 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!

Read this, the "CentOS7 how to reset root password" article has been introduced, want to master the knowledge of this article also need to practice and use to understand, if you want to know more about the article, welcome to follow the industry information channel.

Tags: Password customer client file article interface success content system problem proper outrageous operating system enterprise location cursor only backward as above ideas Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux OPPO Reno Huawei Docker MariaDB