Reset Ubuntu Server Password from GRUB
Resetting a Forgotten Ubuntu Password via GRUB
If you've forgotten your Ubuntu server password, you can reset it using the GRUB boot menu. You can reset via one of these two methods: using recovery mode or editing the GRUB boot parameters.
Method 1: Using Recovery Mode
This method is recommended for most users as it is more straightforward.
- Reboot the server.
- While the server is starting, press and hold Shift (or Esc for UEFI systems) to display the GRUB menu.
- In the GRUB menu, select Advanced options for Ubuntu and press Enter.
- Choose the entry that includes
(recovery mode)and press Enter to boot into the recovery menu. - Select root: Drop to root shell prompt and press Enter.
- By default, the file system is mounted as read-only. Remount it with read-write permissions:
mount -rw -o remount / - To find your username (if you don't know it), list the home directories:
ls /home - Reset the user's password:
Replace
passwd <username><username>with your actual username. Follow the prompts to set the new password. - Type
exitto return to the recovery menu. - Select resume: Resume normal boot to restart your server.
info
After reboot, you can log in with the new password.
Method 2: Editing GRUB Boot Parameters
This method boots directly into a root shell, skipping the recovery menu.
- Reboot and hold Shift or Esc to enter the GRUB menu.
- Select the standard Ubuntu boot entry and press e to edit.
- Find the line starting with
linux /boot/vmlinuz-.... - Remove the parameters
ro quiet splashand append:rw init=/bin/bash - Press F10 or Ctrl+X to boot.
- The system will boot to a passwordless root shell. Set the password:
passwd <username> - After resetting the password, reboot the system:
exec /sbin/init
caution
Use these methods only on systems you are authorized to access.