How To Reset Root Password On CentOS 7

The way to reset the root password on centos7 is totally different to Centos 6. Let me show you how to reset root password in CentOS 7.

1 – In the boot grub menu select option to edit.


2 – Select Option to edit (e).


3 – Go to the line of Linux 16 and change ro with rw init=/sysroot/bin/sh.


4 – Now press Control+x to start on single user mode.


5 – Now access the system with this command.

chroot /sysroot

6 – Reset the password.

passwd root

7 – Update selinux information

touch /.autorelabel

8 – Exit chroot


9 – Reboot your system


That’s it. Enjoy.


  1. this just screwed my whole system. After trying this all users are gone. And after entering “exit” you can reboot, it says :

    failed to start transaction is destructive

    Then by turning the server off, it gets stuck now on Started GNOME Display Manager or sometimes in
    started dynamic system tuning daemon

    When I try from the console, not even root has access anymore. Even with the new password.

    you suck.

  2. Ok, so actually the proper way to do this is similar to this, but its the proper way. This will interrupt the boot process properly, before the filesystems are mounted, etc. and with less text addition to grub:

    1. Edit the same line as noted but at the end of the Linux16 line append ‘rd.break’ (add nothing else, and no quotes)
    2. Push ctrl+x to boot the system
    3. mount the file system with ‘mount -oremount,rw /sysroot’
    4. after the system boots run ‘chroot /sysroot’
    5. reset your password using the passwd command
    6. make the /.autorelabel file, if you fail to do this then the selinux contexts will not be restored to your /etc/passwd and /etc/shadow files which will cause some major issues: ‘touch /.autorelabel’
    7. type ‘reboot’ or ‘systemctl reboot’
    8. all done

  3. Hello Scristopher, this worked for me, though reboot gave me error, ‘reboot -f’ worked.

  4. Hi,
    Thank you for this valuable article. I got a problem when I try to reboot the system after reset root password, then an error msg given ” Failed to start Transaction is destructive.” Please let me know the solution. Thanks.

  5. Hi, I have same problem like Saidur Rahman has, and I’ve tried with ‘reboot -f’ option that worked like a charm, problem is that I don’t have users anymore after Centos 7 GUI loads, so I go to terminal screen with ‘Ctrl+Alt+F2’ and on the login I’m typin user root but it says that password that I’ve changed isn’t correct. Does anyone has idea what could I do as next step? Thanks in advance…

  6. ‘reboot -f’ worked for me, but as I’ve mentioned in my comment, after normal boot new root password is not accepted… 🙁

  7. Thank you for your reply. ‘reboot -f’ worked, but root password not working. But recently I have changed my root password from single user mode.

  8. thank you for the guide with centos 7. I did find however changing the passwd would not working unless i specified: sudo passwd root


Please enter your comment!
Please enter your name here