Have you encountered this situation: the user can not remember the account password on the Linux system, if you forget the root password, the situation is even worse?. You can not execute any changes for the entire system. If you forget your password, it is easy to use the root account to reset your password.
But if you forget the root account password, what shall we do? You can not use the root user account to reset the account password because the user account is usually not allowed to perform this task.
In case you encounter such a situation, this guide can help you get rid of such articles predicament. This article describes how to reset RHEL 7 and CentOS root account password 7 under.
Early this morning, I opened the RHEL 7 Linux server, only to find it was locked. I messed up the night before the password is not changed, that is indeed forgotten password.
Well, I now what to do? Should I use a user account to log on, you try to change the root account password
Unfortunately, I see the message is "Only root can specify a user name" ( "Only root account to specify a user name"), I lost control of the root account. So I intend to boot into single-user mode. To do this, reboot the server; once you see the following screen, you press the "e" on the keyboard (for editing).
You press the "e" on the keyboard, you'll see a lot of text, the text will be shortened according to the screen size.
Search Text "rhgb quiet", it will be replaced by "init = / bin / bash", without the quotes.
Once you finished editing, press "ctrl + x" key combination, it will start with the specified parameters to boot. You'll get bash prompt.
Now, run the following command on a single-user mode, check the status of the root partition.
# Mount | grep root
You may have noticed that the root partition is reported as "ro" (read only). We need to have the root partition read-write permission to change the root account password.
# Mount -o remount, rw /
Also repeatedly check to see if the root assign read-write access mode to mount.
# Mount | grep root
Now you can change the root account password, just type passwd command. But it does not end. We need to re-tag SELinux context. If we skip SELinux relabel the entire context of this step, it is possible to log in using using password.
# Passwd root
[Enter New Password]
[Re-enter the new password]
# Touch /.autorelabel
Restart, once again log into the root account to see if everything is not normal?
# Exec / sbin / init
We have by resetting the root account password from a single-user mode, successfully logged into RHEL 7 system.
Several steps above clearly shows how to reset the root account password from a single-user mode, log on to RHEL 7 and CentOS 7 machines.