How to Change Root Password on Ubuntu 24.04


In Ubuntu or any other OS, changing the password of the primary account is the essential activity of an administrator. The root user is the user with all the privileges and it is recommended to keep changing the root password frequently.

By changing a root password, it becomes more secure and difficult to breach as compared to an account that has not changed the password.

This post will demonstrate the possible methods to change the root password on Ubuntu 24.04, Noble Numbat.

Outline:

How to Change the Root Password on Ubuntu 24.04

The root password can be changed if you are logged in as a root user of the user that has the sudo/root privileges. Additionally, you can enter into recovery mode and change the root password too.

Let’s discuss these scenarios:

Method 1: Log In as a Regular User

If you are a regular user but have the sudo privileges, you can change the root password using the command:

sudo passwd root

Note: You can change any user’s password using the same syntax:

sudo passwd <username>

Method 2: Logging In/Switching as a Root

The root user is the most privileged user and it allows you to change its own password using the “passwd” command. First, log in/switch as a root and then use the “passwd” command:

su
passwd

The “su” command switches you to the root user:

Note: You can use the following commands to switch to the root user:

sudo i
su -
sudo su

Method 3: Entering/Logging Into Recovery Mode

Ubuntu 24.04 offers the recovery mode (like the previous releases of Ubuntu). The recovery mode allows you to access your file system (in either read-only or read-write) and make the suitable changes, i.e., changing the root password:

Step 1: Enter/Boot Into Recovery Mode

Enter the GRUB menu after rebooting and select the “Advanced options for Ubuntu”:

Now, choose the recovery kernel to boot into:

Step 2: Drop Into Root Shell

Inside the recovery mode, enter/drop into the root shell:

When you press enter, you will be asked to enter the root password for the maintenance:

Step 3: Change the Root Password

After successful authentication, you will be finally logged in as a root user. Now, set the password using the “passwd” command:

That’s how you can change the root password on Ubuntu 24.04.

Troubleshooting Fix: Fixing the “passwd: Authentication token manipulation error”

While changing the root password, you might get the “Authentication token manipulation error”. This is because your filesystem is mounted with read-only permissions and you are unable to change the password.

To fix it, you need to execute the below command to temporarily mount the filesystem with the read-write permissions:

mount / -o remount,ro

Now, use the “passwd” command and you will be able to change the password successfully.

How to Reset a Lost/Forgotten Root Password on Ubuntu 24.04

If the root password is forgotten/lost, you won’t be able to execute commands or do any operation that requires access to the root user account. However, you can still access the system and change the root password. Here’s how it works:

Step 1: Enter the GRUB Menu

Enter the grub menu and press the “e” key to change the commands for the system login:

Step 2: Temporarily Mount Your Filesystem With Write Permissions

At the moment, the filesystem is mounted with read-only permissions thus you won’t be allowed to write any operation on your disk. To change it to write mode, find the line starting with “linux”:

Navigate to the end of that line and replace the keyword “ro” or “ro quiet splash $vt_handoff” with “rw init=/bin/bash”:

Press “CTRL-X” to boot with this setting

Step 3: Change the Root Password

Now, set/change the root password using the passwd command:

passwd

After changing the password, you might not be able to reboot your system using a simple reboot command. You can reboot your system via the following command:

exec /sbin/init

Your root account can now be logged in with the password you set up in Step 3.

That’s how you can manage the root password on Ubuntu 24.04, Noble Numbat.

Bottom Line

It is recommended to keep changing the root password frequently to stay safe from any breach. To change the root password, either switch to the root user and use the “passwd” command or use the “sudo passwd root” command with any user that has the root privileges.

Apart from that, you can also change the root password if you do not remember the current root password. In this guide, you have learned all the possibilities to change the root password on Ubuntu 24.04, Noble Numbat.

Print Friendly, PDF & Email
Categories