Reset root password in CentOS 7
Posted on Mon 25 April 2016 in System Administration
Following steps will guide you in resetting root password
-
Restart the CentOS 7 system
-
Press any key to interrupt the boot loader countdown
-
Select Linux Kernel line which needs to be booted
-
Press e to edit the select Linux Kernel entry
-
Append
rd.break
at end oflinux16
line -
Press CTRL + x to boot system
-
Mount /sysroot in read-write mode
switch_root:/# mount -oremount,rw /sysroot
-
Switch into a chroot jail environment
switch_root:/# chroot /sysroot
-
set a new root password
sh-4.2# passwd root
-
To enable SELinux relabeling of
/etc/shadow
file, create a empty file likesh-4.2# touch /.autorelabel
-
Press
exit
twice to exitchroot
andinitrdramfs
shell