Reset CentOS-7 Lost Root Password

Home » CentOS » Reset CentOS-7 Lost Root Password
CentOS 5 Comments

Hie

I lost my CentOS 7 root password, so I tried booting the OS in single user mode but it prompts me for the root password when the system boots,

Any ideas?

Regards

Bonnie

5 thoughts on - Reset CentOS-7 Lost Root Password

  • Should be do-able without the live CD:

    At the GRUB menu, edit the kernel line, add init=/bin/sh to the end of it and boot from that.

    You’ll end up at the shell prompt, where you can change the password with the normal passwd command.

    You may need to:

    – mount -o remount,rw on your root partition before you’ll be allowed to write any changes
    – touch /.autorelabel to make sure SELinux doesn’t refuse the changes after you reboot (if you’re enforcing SELinux, obviously)

    You should then be fine to reboot and log in using the fresh password.

    Not as elegant as just sticking a 1 on the end of the kernel line to get to single-user mode, but whatever, it works.

    Paul

  • Didn’t realise that tool existed. That’s a useful one, thanks.

    Also just realised the previous top-post. Sorry list.

    Paul