How to reset password in Redhat Linux?
If You forget root user password of Linux machine. Then you can reset your root account password by using below easy steps. But you have to take down time first then you can process.
Reboot and edit grub2 :-
1. First of all, reboot your server and press any key to stop auto-boot from the kernel. Then press after scroll down to kernel line (Rescue Mode).
2. When you are in edit mode, go to the line starting with linux16 and edit rd.break like shown in below picture.
Note - You can edit also enforcing=0 options enables omitting the time consuming SELinux relabeling process.
3. Then press Ctrl +X and this will reboot the system into rescue mode with changed parameters.
Note - Now the file system is mounted in read-only on /sysroot/.
4.So now you have to remount /sysroot file system in read-write mode and then use chroot to get in chroot jail.
# mount -o remount,rw /sysroot
# chroot /sysroot
5. Now you can change your root account password by using passwd command.
#passwd
6.After that all unlabeled files ( including shadow file ) gets relabeled during booting. Touching the hidden file autorelabel instructs SElinux to relabel the files changed outside of its regular context, like the file /etc/shadow.
# touch /.autorelabel
7. To flush all cache to disk.
# sync
After that type exit command two times for reboot the system. Then you can login with updated password.