How to change root password in Ubuntu 24.04. Read this tutorial to find how to reset forgotten root password in Ubuntu Linux.
Regular User – Changing Root Password
To update or change the root password in Ubuntu 24.04 with sudo privileges, simply run the “passwd” command with the sudo privileges:
sudo passwd root
Root User – Changing Root Password
To change the password as a root user, first you will have to switch to the “Root User”. To do so, run the following command to log in as a root user:
sudo su -
Now run the passwd command to change the root password:
passwd
Once the root password is changed, exit from the root user – type exit in the terminal.
Resetting the Forgotten Root Password Using Recovery Mode
You can easily reset the forgotten root password from the recovery mode. Simply go through the following steps:
Step 1 : Boot into recovery mode and drop to root shell prompt. To do so, fresh start the system and while the machine is booting, press and hold the “ESC” key (press and hold the Shift key (for systems with BIOS) or the Esc key (for systems with UEFI)) from your keyboard to enter the GRUB menu. From there, select the “Advanced options for Ubuntu” using the arrow keys and hit the Enter key to proceed.
Step 2 : Now select the highlighted option and press Enter to boot the system into “recovery mode” and from the recovery menu, select the “Drop to Root Shell Prompt” option and press Enter. After this you will be asked to provide the root password for maintenance.
Step 3 : Enter the current root password and press Enter to log in as a root user.
Step 4 : Once you are logged into the root user, execute the following command to remount the root filesystem:
mount -rw -o remount /
Step 5 : Now run the passwd command to easily reset your forgotten root password:
passwd root
Once you are done, run the “exit” command to exit from the root shell prompt and go back to the recovery menu. From there, select the “Resume Normal Boot” option.
That’s all, now you shall be able to log in with the new root password.