Getting locked out of your own computer is a uniquely stressful experience. In the Windows ecosystem, a forgotten password often requires downloading third-party password cracking utilities to a USB drive. However, the Linux architecture approaches system recovery entirely differently. If you have lost the administrator password to your server or personal workstation, you do not need external software to break back in. By understanding the underlying boot sequence, you can learn how to reset a forgotten root password in Ubuntu Linux using GRUB, effectively pausing the boot process and launching an emergency administrative terminal.
In this advanced system rescue guide, we will walk you through the precise keyboard timing required to access the GRUB menu, the exact kernel parameters you must edit to bypass the standard login screen, and the terminal commands necessary to force a password change at the highest system level.
What is GRUB and Why Are We Editing It?
GRUB (GRand Unified Bootloader) is the first piece of software that loads when you turn on your Ubuntu machine. It is responsible for locating the Linux kernel on your hard drive and executing it.
Normally, GRUB automatically boots the system into its standard, secure state, eventually presenting you with the graphical login screen. However, by intercepting GRUB before the boot sequence finishes, we can manually append temporary instructions to the kernel. Specifically, we will instruct the kernel to mount the hard drive with read and write permissions and immediately launch a root bash shell (a high-level command terminal) instead of the normal graphical interface. Because this shell operates at the root level, it completely bypasses the need for your forgotten user password.
Step 1: Accessing the GRUB Menu
The GRUB menu is often hidden by default on modern Ubuntu installations to speed up boot times. You must force it to appear.
- Turn your computer completely off.
- Press the power button to turn it on.
- Immediately after your computer’s manufacturer logo (e.g., Dell, Lenovo, ASUS) disappears, press and hold the Shift key.
- Note: If you are using a modern UEFI-based system and the Shift key does not work, try rapidly tapping the Escape (Esc) key instead.
- If successful, the boot sequence will pause, and you will see a stark, black screen with a list of options, typically starting with “Ubuntu” and “Advanced options for Ubuntu”. This is the GRUB menu.
Step 2: Editing the Boot Parameters
We must now modify the instructions for the primary boot option.
- Ensure the top option (usually just Ubuntu) is highlighted in white. Use your keyboard arrow keys to move the selection if necessary.
- Press the ‘e’ key on your keyboard. This opens the GRUB editor, revealing the raw code used to boot the system.
- Use your arrow keys to scroll down through the code. You are looking for a specific line that begins with the word
linux. It is usually a very long paragraph of text. - Move your cursor to the very end of this
linuxline. You will likely see text likero quiet splash $vt_handoff. - Carefully delete the words
ro quiet splash $vt_handoff. - In their place, type the following exact command:
rw init=/bin/bash
What this does: rw tells the system to mount the hard drive with Read/Write permissions (normally it boots as Read-Only, ro). init=/bin/bash tells the kernel to launch the bash terminal immediately upon booting, ignoring the standard startup scripts.
Step 3: Booting into the Root Shell
Once you have double-checked your typing to ensure the syntax is perfect, press Ctrl + X (or F10) on your keyboard.
The screen will briefly flash black, lines of text will scroll quickly, and then the process will stop. You will be left staring at a stark, minimalist command prompt ending in a hash symbol (#). You now have absolute root access to your machine.
Step 4: Resetting the Password
Because you are already the root user, you do not need to use the sudo command, nor do you need to know the old password to create a new one.
- At the command prompt, type the password command followed by your specific username. For example, if your username is “john”, type:
passwd john - Press Enter.
- The terminal will prompt you to “Enter new UNIX password:”. Type your new, highly secure password. Note: Linux does not display asterisks or characters when you type passwords in the terminal. The cursor will not move. This is a security feature; simply type it and press Enter.
- The terminal will ask you to “Retype new UNIX password:”. Type it exactly as before and press Enter.
- If successful, you will see the message:
password updated successfully.
Step 5: Safely Rebooting the System
Because we bypassed the standard boot sequence, we must force a safe reboot to return to the normal graphical environment.
- At the prompt, type the following command to sync the file system and force a reboot:
exec /sbin/init - Press Enter.
- The computer will reboot normally. The GRUB menu will be hidden, and you will be presented with your standard graphical login screen. Enter your newly created password to access your desktop.
Security Considerations
While this process is incredibly useful for recovery, it highlights a terrifying security reality: anyone with physical access to a Linux machine can reset the password and access your data within three minutes. If you are using Ubuntu on a corporate laptop or in a shared environment, the only way to prevent this exploit is to enable Full Disk Encryption (LUKS) during the initial operating system installation. If the drive is encrypted, launching the bash shell via GRUB will only present the attacker with scrambled, unreadable data.
Losing administrative access does not require a total wipe of your hard drive. By mastering how to reset a forgotten root password in Ubuntu Linux using GRUB, you leverage the flexibility of the open-source architecture to effortlessly rescue your system from catastrophic lockouts.