How to recover Ubuntu user password

6,663

Solution 1

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

Solution 2

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:
6,663

Related videos on Youtube

flamey
Author by

flamey

Updated on September 17, 2022

Comments

  • flamey
    flamey over 1 year

    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?

  • Telemachus
    Telemachus over 14 years
    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.
  • Paul Tomblin
    Paul Tomblin over 14 years
    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.
  • wfaulk
    wfaulk over 14 years
    I'm pretty sure that single user mode requires that you type in the root password.
  • wfaulk
    wfaulk over 14 years
    @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.
  • Telemachus
    Telemachus over 14 years
    @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.
  • quack quixote
    quack quixote over 14 years
    single mode does prompt for root password, but there's a message that suggests Ctrl-D may allow accessing the system without a password anyway. (might just initiate a reboot.. not sure, i've never had to boot to single when i didn't know the password.)
  • quack quixote
    quack quixote over 14 years
    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.)
  • wfaulk
    wfaulk over 14 years
    @Telemachus: yeah, but you can always boot off of another CD.
  • Telemachus
    Telemachus over 14 years
    @Wfaulk: Sure. I just wanted to warn the OP that the method Mark suggests may not work with Ubuntu, because I vaguely recall that method was blocked. I may completely wrong about that, but I never said anything about an airtight system.