0

A while ago I've installed Ubuntu as a second OS on my laptop, just to try out Linux. I have created one user & gave it admin privileges.

Haven't touched it for a while, and, of course, forgot the password. Tried all my commonly used passwords for that user and root, but they don't work.

Is there a way to recover passwords somehow?

2 Answers 2

5

Copied and pasted from http://www.ubuntugeek.com/how-to-recover-password-under-ubuntu.html

Press ESC at the grub prompt.

Press e for edit.

Highlight the line that begins kernel ………, press e

Go to the very end of the line, add rw init=/bin/bash

press enter, then press b to boot your system.

Your system will boot up to a passwordless root shell.

Type in passwd username

Set your password.

Type in reboot

8
  • I think that more recent versions of Ubuntu may block this method (it is a gaping security hole), but it's still worth a shot.
    – Telemachus
    Oct 1, 2009 at 23:41
  • 1
    Similarly, instead of "rw init=/bin/bash", the more traditional way is to say "single" to boot in single user mode. I think that still works on Ubuntu. Oct 1, 2009 at 23:42
  • I'm pretty sure that single user mode requires that you type in the root password.
    – wfaulk
    Oct 1, 2009 at 23:43
  • @Telemachus: If you have access to the hardware, there's not really much anyone can do to keep you from the data. I suppose a completely encrypted filesystem might.
    – wfaulk
    Oct 1, 2009 at 23:45
  • @Wfaulk: grub can easily be configured so that it requires a password in order to edit the boot line. I do this on my Debian installation, for exactly this reason. I think that Ubuntu might now do this by default, but I am not 100% sure of that.
    – Telemachus
    Oct 2, 2009 at 0:01
1

Easiest way in general to recover a password under Linux is to boot from the install CD in recovery mode, mount the root filesystem at /mnt (or anywhere, really), and edit the /mnt/etc/passwd and /mnt/etc/shadow files to remove the password fields. Then unmount the root filesystem and reboot. Now you should be able to log in as that user with no password.

The "init=/bin/bash" suggestion above is very cool, though.

1
  • You could also chroot into your mounted filesystem and use the passwd tool from there. (As root, or sudo'd, passwd won't ask for the current password before setting a new one.) Oct 2, 2009 at 0:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .