Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In my PC, Linux is already installed and I forgot the password. I want to recover my Linux system password. How can I do it, step by step?

share|improve this question

migrated from Sep 14 '10 at 9:37

This question came from our site for professional and enthusiast programmers.

There is no way to recover a password.

You can boot a different installation (e.g. from DVD), mount the partition with /etc/shadow and clear the password (set it to the empty string). You can also try to run a password cracker on the file if you really need to know what it was.

share|improve this answer
+1 for the recovery vs reset distinction, though i think in this case the OP really wanted access to the system rather than actually "recovering" as such. – Sirex Sep 14 '10 at 10:15
@Sirex: Will be interesting to see which, if ANY answer gets accepted. :-) – hotei Sep 14 '10 at 16:09

init=/bin/bash is by far NOT the easiest way to do this. Boot into single user mode.

From the boot loader, instead of init=/bin/bash, just add the word "single" (without quotes).

The system will boot up as usual but drop you to a Bash prompt never asking you for a password and already having mounted the system as rw. Then reset your password with the passwd command.

When you're done run

init 3  

for CLI startup


init 5 

for GUI.

No mounting, remounting, rebooting, booting from live CDs or distributions are needed when done.

share|improve this answer
Many linux distro do ask for the root password when you boot single. It depends on the settings in /etc/inittab, I think the 'secure'/'unsecure' line. – lorenzog Sep 16 '10 at 12:35
-1, ditto to @lorenzog's comment – Kimvais Feb 8 '12 at 9:05

Fastest way is to pass the parameter init=/bin/bash to the boot loader (see an example here). That would give you a root console pretty much immediately, now mount -a and mount -o remount,rw / to get access to the system. Finally, a passwd command should allow you to set the root password.

Second option (since nowadays linux distro need a ramdisk with drivers when they start) is to boot with a live distro, then mount your linux partition somewhere (a-la mount /dev/sda1 /mnt), mount also /proc and /dev (devfs usually) into the new partition (mount --bind /proc /mnt/proc and mount --bind /dev /mnt/dev). Finally, chroot /mnt and mount -a should give you your system back. Now, sometimes live distro see your hard disk as sd (the old SCSI mapper, now used for SATA disks), so you might end up with /dev/hda mapped to /dev/sda. That were the case you need to mount by hand all that you find in your /mnt/etc/fstab file. Once that's done you can try the chroot again, and then passwd.

If you find this complicated learn the lesson: (1) don't use root (2) don't use root (3) use sudo

share|improve this answer
+1 since this is a method that works on linuxes that have broken the single user mode. – Kimvais Feb 8 '12 at 9:05

Your system password? Do you mean the root password?

Assuming you still have your password and you are in the sudoer list, you can set a new root password by running passwd as root. Something like

sudo passwd
share|improve this answer
this is the easiest way if the user is in the sudoers list. It should get more upvotes. – wullxz Nov 19 '11 at 10:48

You must log in to answer this question.