How to Reset a Forgotten Ubuntu Root Password
If you have forgotten your root or administrative password in Ubuntu, you can regain access by booting into the GRUB recovery menu and using the root shell prompt. This guide provides a straightforward, step-by-step walkthrough to safely reset your user or root password without losing any of your data.
Step 1: Boot into the GRUB Recovery Menu
To start the password reset process, you need to interrupt the normal boot sequence of your Ubuntu system.
- Reboot your computer. 2. Immediately press and hold the Shift key (for older BIOS systems) or tap the Escape (Esc) key repeatedly (for newer UEFI systems) as the machine starts up. This will trigger the GRUB bootloader menu to appear.
- Use the arrow keys to navigate to Advanced options for Ubuntu and press Enter.
Step 2: Access the Root Shell Prompt
Once inside the Advanced options menu, you will see a list of available Linux kernels.
- Select the line that ends with (recovery mode) and press Enter.
- Wait for the system to load the Recovery Menu.
- Use the arrow keys to scroll down to the option labeled root Drop to root shell prompt and press Enter.
- Press Enter once more when prompted at the bottom of the screen to activate the CLI environment.
Step 3: Remount the Filesystem with Write Permissions
By default, the recovery shell grants you read-only access to the file system. You cannot change a password unless you grant the system permission to write data.
To change the permissions, type the following command exactly as shown and press Enter:
mount -o remount,rw /
Step 4: Reset the Password
With write permissions enabled, you can now change the password for your administrative account.
- Type the following command, replacing
usernamewith your actual Ubuntu username, and press Enter:passwd username(Note: If you specifically locked the actual “root” account, you would just typepasswdinstead). - The system will prompt you to Enter new UNIX password. Type your new password and press Enter.
- The system will ask you to Retype new UNIX password. Type it again and press Enter.
Note: The terminal will not display any characters, stars, or dots while you type your password. This is a standard security feature in Linux.
Step 5: Reboot Your System
Once you see a message stating “password updated successfully,” your new credentials are saved.
- Exit the root shell by typing:
exit - You will be returned to the main Recovery Menu. Select resume Resume normal boot and press Enter.
Your Ubuntu system will finish booting up normally, and you can now log in using your newly created password.