resetting the root password in linux

Posted on

Problem :

How do I reset the root password in fedora ? Is there any way out ? I have googled a lot but couldn’t find any useful result.

Solution :

the Fedora documentation gives Information on how to reset the root password.

You can also use this more general approach here with init=/bin/bash which works
on about any distro.

This is from the Ubuntu documentation:

  1. Reboot your computer

  2. Press SHIFT or ESC at the grub prompt (as earlier).

  3. Select your image.

  4. Highlight the line that begins kernel and press ‘e’ to edit

  5. Go to the very end of the line, change the ro to rw and add init=/bin/bash

press enter, then press b to boot your system.

Your system will boot up to a passwordless root shell.

  1. Type in passwd username

  2. Set your password.

  3. Type in reboot

This should work,too

With sudo access:

When you at least have sudo access to the machine you can use sudo bash to aquire a root shell and passwd afterwards.

With chroot:

Another way would be to boot from a LiveCD (or USB Stick with a live System). Then you have to mount your system partitions. At least the ones containing /etc and the location of passwd, probably /bin check with which passwd.
Afterwards you chroot into that directory.

 mount /dev/sda1 /mnt/system
 mount /dev/sda2 /mnt/system/etc
 chroot /mnt/system /bin/bash

Now you are virtually inside your new environment and can use passwd. Maybe you have to update your environment with hash -r before.

This works in debian distros, should work in Fedora I think (assuming you have sudo privs)

sudo passwd root

type and verify the new password and done.

Leave a Reply

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