How to Reset root Password in Linux
There are two scenarios in which changing the root password becomes essential. You know the current password and want to update it for security or other reasons. You forgot the current password and want to set a new password. This tutorial explains both situations.
Changing or updating the current root password
Log in from the root user account if you know the current password. After login, open a terminal to access the shell prompt if you are on GUI. The shell prompt is default on CLI. Use the passwd command to change the current password. The passwd command updates the existing password for the specified user account. If no user account is provided, it updates the password for the user account under which it runs. Execute it without passing a username to change the root password.
#passwd
Set the desired password.

To verify it, log out from the current session and log in again with the updated password.
Resetting a forgotten root password
The following are two ways to reset a forgotten root password.
- Using a super user account
- Using the single-user or maintenance mode
Using a super user account
The wheel group is the default privileged group. Members of this group are super users. The installation process includes an option to add a regular account that we can use to log in just after the installation. If we use this option, the installation process creates the user account and adds it to the wheel group. After installation, use the following command to add a user account to this group.
#usermod -G wheel [username]
If you know the password of a super account or the account created during the installation process, log in from it, access a shell prompt, and run the following command.
$sudo passwd root
Use the user account password you used to log in to authenticate the action and set the new root password.

Using the single-user or maintenance mode
If you do not have a superuser account or have not added a user account during the installation, you can not use the passwd command to reset the root password. The passwd is a privileged command. Only a root or super user account can specify a username or change the password for another user account. A regular user can run it without specifying a username to change his own password. He is not allowed to provide a username. Therefore, you cannot reset a forgotten root password on the running system if you do not have a superuser account.

In that case, you can reset the forgotten root password in the maintenance mode. The maintenance mode runs under the root privilege. You can run all privileged commands in this mode. Restart the system. On the GRUB boot screen, press the e key to interrupt the boot process.

Move to the line that starts with the keyword linux. Add the rd.break option at the end of this line. This option instructs the kernel to boot the system in the rescue mode.
Press Ctrl+x to start the boot process. The system boots with the updated parameters and presents the switch_root prompt. The boot process mounts the file system with the read-only option. This option does not allow us to change configuration files. The /etc/shadow file saves passwords for local user accounts. The passwd command needs write access to this file to update the password. The following command remounts the file system as writable.
# mount -o remount,rw /sysroot
Change the base file system to the file system installed on disk.
# chroot /sysroot
Use the passwd command to reset the root password. The maintenance mode starts under the root account. Without a username, the passwd command changes the password for the current user account. Since the current user account is root, it changes the root password.
# passwd

SELinux sets and monitors security contexts on files. It keeps a snapshot of all security contexts. Since we modified a file in the maintenance mode, its security context does not match the saved context. Use the following command to relabel all security context at the next system boot.
# touch /.autorelabel
Exit the installed file system.
#exit
Exit the maintenance mode.
#exit
The relabeling process may take a longer time if the system has a large number of files.

After the system boots, use the updated password to log in from the root account.
A successful login verifies the root password change.
Conclusion
The root user account is the primary administrator account on a Linux system. It has unrestricted access to the file system. It allows you to configure, change, or delete any settings. This tutorial explained how to change or reset the forgotten root user password.
By ComputerNetworkingNotes Updated on 2025-10-20