Open In App

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.

Reset password using recovery mode.

Step 1: During startup, from the Grub menu select “Advanced options for Ubuntu”.



Selecting advanced options in the Grub menu

Step 2: In the next screen go to recovery mode.

Selecting recovery mode

Step 3: Choose “root Drop to root shell prompt” from the Recovery menu and press Enter.



Recovery menu

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.

mount -rw -o remount / 
ls /home
passwd username
New password:
Retype new password:
passwd: password updated successfully
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.

Alternate method to reset Linux password.

Step 1: From the Grub menu press “e” to edit commands before booting.

Unedited grub commands

Step 2: In the line starting with linux, edit ro to rw and append init=/bin/bash at the end of that line.

Edited grub commands

Step 3: Press Ctrl+X to boot into the root shell.

Step 4 :Next, proceed by entering the following commands to reset the password.

ls /home

passwd username

New password:
Retype new password:
passwd: password updated successfully

/sbin/reboot -f

Commands to reset password

Now you can use the system with a new password.

Conclusion

in this article we discussed that how to reset a lost password in a Linux distribution, primarily Ubuntu 23.04 but applicable to other versions and distributions. It offers two methods: one via recovery mode and an alternative through editing boot commands. The concise, step-by-step instructions are accessible to all users and emphasize password security. This article serves as a valuable resource for those locked out of their Linux systems, ensuring they can regain access quickly and securely.

Article Tags :