Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

up vote 5 down vote accepted

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

share|improve this answer
    
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 '09 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. –  Paul Tomblin Oct 1 '09 at 23:42
    
I'm pretty sure that single user mode requires that you type in the root password. –  wfaulk Oct 1 '09 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 '09 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 '09 at 0:01

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.

share|improve this answer
    
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.) –  quack quixote Oct 2 '09 at 0:10

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.