Reset password using recovery mode.
Step 1: During startup, from the Grub menu select “Advanced options for Ubuntu”.
Step 2: In the next screen go to recovery mode.
Step 3: Choose “root Drop to root shell prompt” from the Recovery menu and press Enter.
Step 4: Press Enter again to access the root shell prompt.
Step 5 :Next, proceed by entering the commands given below to reset the password.
- To get write access to the root partition execute the below command.
mount -rw -o remount /
- If you don’t know your username, use the following command to list all users.
ls /home
- Now to reset the password execute “passwd username”, your username should replace the username.
passwd username
- Enter a new password and retype the new password to confirm it (Note: Linux does not display the password you typed, just type and press Enter)
New password:
Retype new password:
passwd: password updated successfully
- Now you have successfully changed your password. Execute “reboot” to restart the system.
reboot
Step 6: Now you can log in to the system as normal with the new password.
Note : If the above method does not work, use the alternate method given below.
How to Reset a Lost Password in Ubuntu and Other Linux Distributions
This article explains how to reset lost a password in a Linux distribution. If you have forgotten your Linux password, this article is undoubtedly for You. This guide uses Ubuntu 23.04, but the same method applies to other versions of Ubuntu and other Linux distributions.