General discussion


Need help recovering root password in Ubuntu

By Jay Garmon Contributor ·
Like any good Linux system, my Ubuntu 5.10-installed laptop protects root access with a password. Unfortunately, I have no idea what this password is, and I'm certain I wasn't prompted to specify it during install. I can obtian root access by interrupting GRUB during the boot process and booting into Recovery Mode. This automatically logs me in as root, without requesting a password. I'd like to find the root password so I don't have to reboot anytime I need root permissions. Any idea how I can find my root password?

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Comments

Collapse -

by Wally Bahny In reply to Need help recovering root ...

All you have to do is type "sudo [your favorite editor here] filename". Then sudo will prompt you for _your_ password, which will give you root-level access to that file. Ubuntu has a nifty feature which disables the root account by default, but gives you this sudo ability as yourself -- kinda similar to the su trick in other distros.

Collapse -

by Jay Garmon Contributor In reply to

Wow. Disabled root account. Totally didn't see that coming.

Collapse -

by Jaqui In reply to Need help recovering root ...

edit the /ect/password or /ect/shadow file to change the password for root to be an empty pair of single quotes ''

next boot will have zero password for root.

got yas on this, shadow is an encrypted file not editable even as root

all such changes must be done as root.
su will be your friend for as long as you use linux. :)

Collapse -

by Jay Garmon Contributor In reply to

I'm not planning on trying this, but it's great for reference.

Collapse -

by jmgarvin In reply to Need help recovering root ...

IIRC, Ubuntu doesn't really "have" a root account. You have to sudo everything.

So, say you wanted to use sudo

sudo <command> <options> <filename if applicable>

If you ever forget the root password, just reboot and in the grub boot screen, edit to start in run level 1.

So, e (for edit), down to where it says kernel /boot/vmlinuz (or whatever) and put a 1 at the very end of that line. Press enter, then b (for boot). You'll be in run level 1 now. So now you'll see a prompt that looks like:

Just type passwd and you've reset the root password to what ever you want.

Hope that helps.

Collapse -

by Jay Garmon Contributor In reply to

Thanks for the sudo tip.

Collapse -

by khushil.dep In reply to Need help recovering root ...

Remeber that sudo is an installable package and may not be availble on all linux boxes you will work on. The shaddow passwords file may also be missing if it is not used by the system. If you really have forgotten your root password and you have no su or sudo available you should mount the drive onto another machine as a secondary HDD and recover your data before wiping the system and doing a re-install. If you are able to hack your own root password out of your box - then the machine is insecure anyway and should be rebuilt.

Collapse -

by Jay Garmon Contributor In reply to

Good point about security.

Collapse -

by djcinsb In reply to Need help recovering root ...

You don't really have to do the reboot gymnastics (oops, wrong olympics!) to set the superuser account to function in Ubuntu. You can just set its password using sudo, and then you'll have a working superuser account. Another alternative can be found in the notes at the top of the unofficial Ubuntu Starter Guide ( "If you are tired of typing "sudo" all the time, switch to root user by issuing "sudo -s -H" followed by user password." That way you can do superuser admin stuff all at once, without actually enabling the account.

(On my install, I just did the passwd piece because I prefer to have the superuser account as an option.)

Related Discussions

Related Forums