Linux TutorialsNew

How To Reset Ubuntu Password?

You may forget your Ubuntu password on occasion. Aren’t you screwed? No, not at all. There are several methods for resetting the root password in Ubuntu. Just keep reading and I’ll give you with solutions. We will accomplish this in three distinct ways.

How To Reset Root Password In Ubuntu?

Option 1 – Root Shell Method 1

  1. Reboot to grub menu
    1. If Ubuntu is the only operating system on your computer, to get the boot menu to show, you have to hold down the Shift key during bootup.
    2. If you have a dual or multi-boot, the boot menu should appear without the need to hold down the shift key.
  2. From the boot menu, select recovery mode and hit Enter.
  3. You’ll be presented with a few options. Select the  Drop to root shell prompt option and then press Enter.
  4. Once you’re at the root shell prompt if you have forgotten your username as well, type​ –
ls /home

This will list all the user accounts in your system.

5. To reset the password, type passwd username where username is the username you want to reset, for example –

passwd ubuntuuser

6. You’ll then be prompted for a new password. Type your new password and then hit Enter.  

7. Now the password should be reset. Type exit to return to the recovery menu.

8. After you get back to the recovery menu, select resume normal boot, and your new password should work now.

Option 2 – Root Shell

  1. Reboot your computer. Follow Step 1 in Option 1 above for a single or dual boot system.
  2. Highlight your image and press E to edit.
  3. Find the line starting with “linux” and append rw init=/bin/bash at the end of that line.
  4. Press Ctrl + X to boot.
  5. Type in passwd username.
  6. Set your password as in OPTION 1 above and restart your PC. Your new password should work now.

Option 3 – Live Disc Or USB

  1. Boot to the Live Ubuntu media.
  2. From the menu, open a terminal.
  3. Find out the device name for your primary disk. sudo fdisk-l will list all partitions. Derive your partition from the list. We’re looking for something like /dev/sda1 (which it will likely be)
  4. Mount this somewhere so we can use it: (Assuming our primary partition is at /dev/sda1)
sudo mount /dev/sda1 /mnt

5. Cross-mount things from the Live install so we can “use” the mounted disk (just copy and paste): for d in dev sys run proc; do sudo mount –bind /$d /mnt/$d; done

6. Become root on the system by running – sudo chroot /mnt You can now do anything root can on the real install.

7. Set the password for the account with: passwd username

8. Reboot and you are done

Conclusion

So that’s how simple it is to reset the root password in Ubuntu. You could also make use of various recovery CDs. Check out this article. Please keep in mind that this constitutes a security risk because anyone with access to your sensitive files might quickly change your password. You should be cautious about who has access to your computer.

If you have any question, please let me know in the comment section below, or join our Discord server.



6 comments

noam September 6, 2019 at 8:12 pm

it started with me wanting to check a nice linux-based product called MailCleaner but then something went wrong with bash so i searched and found how to change bash. then something went wrong with keyboard selection so i tried to reconfigure my keyboard but then something went wrong with path so dpkg was not running so i went to /usr/sbin to shoot the command but then it said keyboard-configuration not install so i went to reconfigure keyboard mappings and it worked but then i found that the password i had for root was not the password i was typing because the mappings on the keyboard changed so then i tried to reset the root password and ended here and guess what…. it doesn’t work.
and here i am after promising myself that this time it can be fixed – no need to reinstall linux….
and all i wanted was a nice email cleaner.
see you in an hour after i reinstall the system.

Reply
Michelle September 15, 2019 at 8:29 am

Thank you!

Reply
Kevinmartin01 April 4, 2020 at 2:16 am

Method 2 saved my bacon so thanks for that. I had locked my root account and it was the only one on the system so, I could not drop to the root shell, it would just hang.

Reply
Shakil Sayyed May 13, 2020 at 9:42 pm

Thank you very much for the solution, Option 1 worked for me perfectly to reset root password.

Reply
Habibie June 7, 2020 at 9:08 am

How to reset root password in Ubuntu 16 server ? I just only have CLI access using putty.

Reply
Chris August 13, 2020 at 1:43 pm

authentication token manipulation error
password unchainged

Reply

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.