20 C
Texas
Mel K
LInux Guru and Technical Writer

How To Reset Root Password On CentOS7 and RHEL7

One of the worst cases in Linux is when you forget your root password and you have no  users with  root sudo privileges to recover the admin password. let me tel you that can be happen even in the big IT companies .

No worry, there is always a solution to reset new password for your Server.

1-Boot menu

On the Grub boor menu , please select last kenel installed, and press  <e>  to Edit

2- Change boot Settings :
- Advertisement -

Please find line starting with linux16 and find  string ro

3- change  ro to  rw init=/sysroot/bin/sh.

 

4-Control+X to start machine in Emergency Shell

5 – Switch into a chroot jail, where /sysroot is treated as the root of the filesystem tree

chroot /sysroot
6 –Now you can Reset the password.
passwd root
7 – Update selinux information to make this permanent
touch /.autorelabel
8 – Exit chroot
exit

9 – Reboot your system with command reboot

reboot
10- Enjoy the New password :

Cheers!!

- Advertisement -
Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

LEAVE A REPLY

Please enter your comment!
Please enter your name here



Latest article