Single User Mode: Resetting/Recovering Forgotten Root User Account Password in RHEL/CentOS 7

Have you ever encountered a situation when you missed your user account password on a Linux System? And the situation can be worse if you forgot the root password. You cannot perform any system wide changes. If you forget user password, you can easily reset it using root account.

What if you forget your root password? You cannot reset root account password using user account. Since user account is not permitted to perform such task in general.

Reset Forgotten root Password in CentOS 7 and RHEL 7

Resetting/Recovering Forgotten Root User Account Password

Well here is the guide which will take you out of any such situation if you ever get into it. Here in this article we will be taking you to the journey of resetting your RHEL 7 and CentOS 7 root password.

This very morning I turned my RHEL 7 Linux server to find out that it has been locked. Either I messed up with password I changed last night or I have really forgotten it.

Forgotten root Password

Forgotten root Password

So what should I do now? Should I login using my user account and try changing root password?

Only Root User Can Set Password

Only Root User Can Set Password

Oops I got “Only root can specify a user name” and I lost my control over root account. So I planned to boot into single user mode. To do this reboot the Server as soon as you get the below screen press 'e' (stands for edit) from keyboard.

Press 'e' to Edit Boot Menu

Press ‘e’ to Edit Boot Menu

After you press 'e' from keyboard you would see a lot of text which may be clipped as per the size of your screen.

Grub Configuration

Grub Configuration

Search for the text “rhgb quiet” and replace it with “init=/bin/bash” without quotes.

Enable Shell

Enable Shell

Once done editing press 'ctrl+x' and it will start booting with specified parameter. And you will get bash prompt.

Booting System

Booting System

Now check the status of root partition by running following command on the single user mode.

# mount | grep root
Check Root Mount Status

Check Root Mount Status

You may notice that root partition is reported to be 'ro' (Read Only). We need to have read-write permission on root partition to change the root password.

# mount -o remount,rw /

Also cross check, if the root partition is mounted with read-write permission mode.

# mount | grep root
Set Permissions on Root Partition

Set Permissions on Root Partition

Now you can change the root password by typing the passwd command. But that is not done. We need to relabel SELinux context. If we skip relabeling the whole SELinux context we would be able to login using using password.

# passwd root
[Enter New Password]
[Re-enter New Password]
# touch /.autorelabel
Reset root Password

Reset root Password

Reboot and login again to root account and see if everything works ok or not?

# exec /sbin/init
Login root User

Login root User

Clear in the above image that we have successfully log-in to RHEL 7 box by resetting root password from single user mode.

The above steps clearly showed how to login to RHEL 7 and CentOS 7 machine by resetting root password from single user mode.

That’s all for now. I’ll be here again with another interesting article soon. Till then stay tuned and connected to Tecmint. Don’t forget to provide us with your valuable feedback in the comments below. Like and share us and help us get spread.

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Support Us

We are thankful for your never ending support.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide
The Complete Linux System Administrator Bundle
Become an Ethical Hacker Bonus Bundle

You may also like...

22 Responses

  1. Rudra M says:

    I have tried above steps but it didn’t work, still not taking a new password that I have set through the above steps. Please suggest how to resolve this?

  2. Vijay says:

    I don’t have root account in my centos 7, and i forgot my user account password.

    What can i do sir?

    • Ravi Saive says:


      root user created by default in each Linux installation, if you don’t know the password, you can set one using this guide.

  3. sara says:


    I had problem with single user mode when I changed file in single user mode and reboot my changes lost, I searched a lot but nothing found to solve my issue.

    any idea?

  4. Vijay says:

    Thanks, It helped to restore the root password.

  5. Mohamed says:


    Thanks it works and My Problem works fine

  6. Sujith Kawashkar A S says:


    I tried a the similar step, but it says user root not found..

  7. Furqan says:

    Hello Sir,

    My problem is centos 7 desktop password change is simply but I want how to lock and security not Change simply next time?

    Please sir help me out quickly…

Got something to say? Join the discussion.

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.