AMP AMP

How to reset Root user password from boot on centos 7

To reset root password from boot on centos 7

The way to reset the root password on centos7 is totally different to Centos 6. Let me show you how to reset root password in CentOS 7.
While turning on the power button, at the grub boot menu press the “ e” key to edit the first boot entry
grub_boot
From the grub options, go to the line that starts with “ linux16”
linux_16

you have to go the end of the line and type “ rd.break” and then press ctrl+x

Now the initrampfs prompt with a root shell will appear at this stage, the root file system is mounted in read only mode to /sysroot and it must be remounted with read/write (rw) permission, so enter “ mount &ndash o remount,rw /sysroot”

once the file system is remounted , change it to chroot jail so that /sysroot is used as the root of the file system.this can be done by running “ chroot /sysroot”

From here the root password can be reset with “ passwd” command.

Now we can reboot but, as centos 7 uses SELINUX enforcing mode by default we have to fix the context of the /etc/shadow file so create “ touch /.autorelabel”

Creating this file automatically perform a relabel of all files on next boot
Type “ exit” twice and machine will reboot, once the reboot is complete the root account will set with a newly set password.

Now the machine will reboot and the login screen appears ,

login using a root user with changed password


with this, the method to reset root password from boot on centos 7 comes to an end.

Tag : CentOS Root
FAQ
Q
What can I do about a "not configured" device?
A
If the device is not one you need, you can safely ignore the not configured warnings.
In some cases, it's just a variation of a supported device. This means it may be relatively easy for a developer to add support for the new card. Otherwise, a new driver would have to be written, which may not even be possible if the device is not fully documented.
Q
Changed password - now can't login to my account (full disk encyption + encrypted home folder)?
A
If you are logged in as another user (e.g. root), then replace the command

ecryptfs-rewrap-passphrase ~/.ecryptfs/wrapped-passphrase
by something like

ecryptfs-rewrap-passphrase /home/[the-user-you-whose-home-you-want-to-rewrap]/.ecryptfs/wrapped-passphrase
or (on a Live CD) by something like

ecryptfs-rewrap-passphrase /[wherever-you-temporarily-mounted-the-home-partition]/[the-user-you-whose-home-you-want-to-rewrap]/.ecryptfs/wrapped-passphrase
Q
can't log in after password change (encrypts)? what will do, please give one solution?
A
login to terminal

$ ecryptfs-mount-private
You need to know your old password to mount.

This will unlock and mount your /home/$USER. At this point, we can access /home/$USER. So just cd back into it and run…

$ ecryptfs-rewrap-passphrase ~/.ecryptfs/wrapped-passphrase
Q
I changed my password then changed it back again. Now I can't get back into my user admin message...could not update ICEauthority file/home/username/.how to recover this?
A
If something is wrong you can fix it with those commands, then logout and login again:

To fix the ownership: sudo chown : /home//.ICEauthority

To fix read/write permissions: sudo chmod 600 /home//.ICEauthority
Q
If there is a root password set and i have forgotten it, but can boot normally and can use sudo?
A
yes, you can use sudo try this from a terminal

# sudo passwd -dl root