-
Reboot Your System:
- Restart your computer and wait for the GRUB menu to appear. If it doesn’t show up by default, hold the Shift key during boot.
-
Edit the GRUB Boot Parameters:
- Once the GRUB menu is visible, highlight the default boot entry (usually the first option, which is your main Ubuntu system).
- Press
eto edit the boot parameters for the selected boot entry.
-
Modify the Boot Line:
- Now you will see the boot configuration for your selected Ubuntu kernel.
- Look for the line starting with
linux. This is where the boot parameters are defined. - Use the arrow keys to navigate to the end of this line and add the following text (after the existing parameters):
init=/bin/bash
This tells the system to boot directly into a bash shell as the root user, bypassing the usual login process.
-
Boot with the Modified Parameters:
- After adding
init=/bin/bash, press Ctrl + X or F10 to boot with these settings. Your system will now boot to a root shell without asking for a password.
- After adding
-
Remount the Filesystem:
- Once you are at the root shell prompt, the filesystem will be mounted in read-only mode. To make changes, you'll need to remount it as read/write:
mount -o remount,rw /
-
Reset Your Password:
- Now, reset your user’s password using the
passwdcommand. Replaceyour_usernamewith your actual username:
passwd your_username
- Enter a new password when prompted. Type it again to confirm.
- Now, reset your user’s password using the
-
Reboot Your System:
- After resetting the password, reboot the system to go back to normal boot:
exec /sbin/rebootOr you can just type:
reboot
- Your system will reboot normally, and you should now be able to log in using your new password.
- You use F2 (or
e) in the GRUB menu to edit the boot line temporarily. - Add
init=/bin/bashto boot straight into a root shell. - Reset your password using
passwd your_username.