In some cases, you may forget the root password on your Ubuntu system or need to regain access if it has been changed without your consent. This guide will show you how to reset the root password safely using GRUB and kernel parameters.
Step 1: Reboot Your Ubuntu System
reboot
To reset the root password, first restart your Ubuntu machine. During the boot process, you need to access the GRUB bootloader menu.
- For BIOS systems: Hold the Shift key during boot.
- For UEFI systems: Press the Esc key repeatedly.
Once GRUB appears, you will see a screen similar to this:

Step 2: Edit Kernel Parameters
When the kernel options are displayed, press e (edit) to modify the boot parameters.
Use the arrow keys to navigate to the line highlighted in the box. Delete the existing line and enter the following:

⬇️
➡️ rw init=/bin/bash
Press Ctrl+X
rw
: Read Write mode
init=/bin/bash
: into the bash terminal
Explanation of Parameters
rw: Opens the filesystem in read-write mode. Normally, during boot, the filesystem is mounted as read-only, and it becomes writable only after certain stages. This allows you to modify files immediately.
init=/bin/bash: Normally, the system boots using init (or systemd), which starts all services and processes. By setting /bin/bash as the init, the system launches directly into a bash shell before the normal boot sequence. This provides root-level access to execute commands like password reset.
Step 3: Reset the Root Password
Once you reach the bash terminal, you now have root access. To reset the password, simply run:
mount -o remount,rw /
Reset Root Password:
passwd root
You will be prompted to enter a new root password. After successfully updating it, ensure the filesystem changes are applied, and then reboot the system.
reboot
OR
exec /sbin/init
By overriding the default init process and mounting the filesystem as writable, you gain direct root access without logging in normally. This is especially useful if you have lost the root credentials or need emergency access to recover your system.