Forgot username/password-locked out

September 9, 2005 at 15:24:42
Specs: Ubuntu 5.04, N/A

So, I've just done the dumbest thing ever...I've locked myself out of Ubuntu. Either the username or password I'm thinking should work isn't, I've tried just about everything it could be...so now I havew to work around it. Is there anything I can do that's quicker than reinstalling it?

Celeron Eater


See More: Forgot username/password-locked out

Report •


#1
September 9, 2005 at 18:11:08

Get a floppy or cd-rom bootable version of Linux such as knoppix. Boot that; then mount the hard drive such as #mount /dev/hda1 /mnt
Edit the /etc/password file for the user which will now be located as:
/mnt/etc/password. You might also need to remove (blank) the password entry for that user in /etc/shadow. You should b able to boot the original Linux and login.

Report •

#2
September 9, 2005 at 23:27:33

First, the file is called /etc/passwd, not /etc/password. You should see your account name in the results of "tail /etc/passwd".

If Ubuntu uses GRUB, and I'm reasonably sure it does, all you have to do is press "e" when it briefly pauses before booting. You will then be able to edit the boot options. Go to the end of the line and enter "init=/bin/bash". This will bypass all startup procedures and give you root access. Run the "tail /etc/passwd" command I mentioned earlier to identify your username. Your root filesystem will be mounted readonly, so you'll want to run "mount -o remount,rw /". Then set your password with "passwd yourusername".

It's possible to password protect GRUB. If you encounter this, use Paracomp's method. You will need to edit etc/shadow. If you completely remove the longest string of junk between two colons, your password will be removed. Reboot, login, and set a new password with "passwd".


Report •

#3
September 10, 2005 at 21:37:52

Thanks Jake for the correction of /etc/passwd
Trying to get over a bout of pneumonia.

Report •

Related Solutions

#4
September 12, 2005 at 03:50:30

With Ubuntu, in the grub boot menu simply choose "recovery mode", this will boot you up to a root prompt without asking for a password. Then you can set a password for yourself as Jake says with "passwd yourusername".

Report •


Ask Question