Whenever you want to perform a task on your operating system that requires root-level permissions, then you must know the root password of your system. Otherwise, you will never be able to log in as the root user. However, at times, it happens that your root password is lost or you do not know it in the first place. In this situation, you should have a mechanism for recovering your forgotten root password, or in other words, you should be able to change your root password.
Here at LinuxAPT, we shall look into different ways of changing the root password on a Linux Mint 20.3 system.
This method can easily be used for changing a forgotten root password or for setting up a root password for the first time. All you need to know is the "sudo" password of your system. You need to execute the below command to begin:
$ sudo passwd root
As soon as you will run this command, you will be asked to enter the "sudo" password of your system. After entering that password, you need to press the Enter key.
Right after entering the "sudo" password of your system, you will be asked to enter a new root password for your system.
When you will enter this password, you will be asked to re-enter it for confirmation.
Once you will do that, a success message will be displayed to you on the terminal that will confirm that the root password of your Linux Mint system has been changed.
This method can only be used if you know your current root password. First, you will have to execute the following command:
$ su root
When you will run this command, you will be asked to enter the current root password of your system.
After adding the current root password correctly, you will gain the root permissions. Then, you will need to run the below command:
$ passwd
When you execute the above mentioned command, you will be asked to enter the new root password.
After entering this password, you will be asked to re-enter it for confirmation.
Again, if both these passwords will match, a success message will be displayed on the terminal.
This article covers the different method of changing the root password of a Linux Mint 20.3 system.