reset root user password rhel7 Centos 7

reset root user password rhel7 and centos 7.  Some times if you forgot root user password, you can’t reset root user password from any other user since Linux is not allowed to reset the root user password from other Normal / Administrator user.

If your going to write RHCSA (Red hat Certified System Administrator) and RHCE (Red hat Certified Engineer) certifications this is the first step you have to resolve.

reset root user password procedure

Authentication Failure

When you type wrong password above authentication failure screen will appear. Then in the top right corner there is a power button will appear as shown in below screenshot, click on power button then click restart

restart server click on power button

Click Restart

Server will restart.

press e to edit arkit

When server is loading boot menu then press any key (Arrow Key / Space Bar) to stop the boot menu, then press ‘e’ to edit the kernel line. Whenever kernel lines are edited below screen will appear

ctrl s

in kernel line where you see “linux16” word go to end of that line and type rd.break console=tty1 then press CTRL+X

server will continue to boot in single user mode. File system in this mode will be in Read Only mode. So we have to remount the file system as Read / Write then only we can able to make a change in configuration files. when we change an Password of root user encrypted password will be stored in /etc/shadow.

remount as read write file system

switch_root# mount -o remount,rw /sysroot

above command will mount an file system as read-write

switch_root# chroot /sysroot

above command will change as actual root

sh-4.2# passwd

above command will change the password of root user

Now root password is changed. 

Note: In RHEL7 by default SELinux is in enforcing state so we have to relabel the SELinux then only server will boot properly when you reboot to do that follow the below steps

sh-4.2# touch /.autorelabel

Above mentioned command will create an hidden file under the slash which means SELinux will auto matically relabel the SELinux policy when server is booting.

That’s it After the successful boot of server use new password to login.

Please provide your valuable comments on the same


reset root user password rhel7, reset root user password centos 7, changing root user password rhel7, how to reset root user password in linux

Thanks for your wonderful Support and Encouragement


My Name is ARK. Expert in grasping any new technology, Interested in Sharing the knowledge. Learn more & Earn More

You may also like...

7 Responses

  1. pabitra says:

    NC by reading here I got many things about Linux..its really amazing..

  2. Harshad Awati says:

    I am very happy here I got lots of info with step by step. It’s amazing. Thank you very much…

  3. Kiran says:

    Ravi Kiran, awesome article….??????

  4. arjun says:

    thanks ….. really amazing

  5. Ankur Sharma says:

    God bless you Ravi.. for this wonderful work of sharing knowledge.. 🙂

Leave a Reply