reset root user password RHEL7 Or Centos 7 Without Rebuilding OS

reset root user password rhel7 and centos 7.  Sometimes 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. Maybe you have to rebuild entire host, using this below method if you have physical access to server you can recover root password.

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 RHEL7

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

Related Articles

Linux Learners Guide Book

RHCSA and RHCE Certification Guide

Thanks for your wonderful Support and Encouragement


Ravi Kumar Ankam

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

12 Responses

  1. blank pabitra says:

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

  2. blank 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. blank Kiran says:

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

  4. blank arjun says:

    thanks ….. really amazing

  5. blank Ankur Sharma says:

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

  6. blank akhil says:

    hi sir. after done this process it is not working it shows me

    [FAILED] Failed to start user manager for UID 42.
    see ‘systemctl status user@42.service‘ for details

    .then what should i do.

  7. blank akhil says:

    hi sir. after done this process it is not working it shows me

    [FAILED] Failed to start user manager for UID 42.
    see ‘systemctl status user@42.service‘ for details

    .then what should i do.
    please reply to me

Leave a Reply

Your email address will not be published. Required fields are marked *