If you are a new Debian admin, you might want to know how to change the sudo password on the shell. After all, it is a good security practice to change passwords regularly for any user, especially the Super User, who can perform all sensitive operations on Debian. Only a Super User or root can change the password for any user account. Other users can only change their own passwords.

User passwords are changed in Debian by using the passwd command.

In this article, we will explain how a root user can change his/her own password on a Debian server.

Step 1: Open the Debian command line

We need to use the Debian command line, the Terminal, in order to change the sudo password. Open the Terminal through the Application Launcher search as follows:

Debian terminal

You can launch the Application Launcher through the Super/Windows key on your keyboard.

Step 2: Log in as root user

Only a root user can change his/her own password. Therefore you need to log in as root first. Enter the following command to do so:

$ sudo -i

The system will prompt you to enter the current sudo password. Please enter the password and hit Enter.

Sudo -i

Now you will be logged in as root user; you can see that in the command prompt.

Step 3: Change the sudo password through the passwd command

Now that you are logged in as root, you can change the passwd for the current (root) user by using the passwd command as follows:

$ passwd

Change password

When you type the passwd command, the system prompts you for the new UNIX root password. If you enter the new password and press Enter, the system prompts you to enter the new UNIX root password again. If you do so, the system will confirm that the password was updated successfully.

Now whenever you need to log in as root or perform any installation and configuration operation that requires root authorization, you will be using this new password.

Step 4: Exit the root login and then the Terminal

When you are done with changing the password, you can log out of the root prompt by entering the following command.

$ exit

Once you are logged out, type the exit command again to exit the Terminal application.

Alternative

A simple alternative is to enter the following command that lets you log in as root and enter the password changing command for root, in a single command:

$ sudo passwd root

When you enter the above command, the system will prompt you to enter the new UNIX root password. When you enter the new password and hit enter, the system will prompt you to retype the new UNIX root password. When you do so, the system will confirm that the password is updated successfully.

With the help of this article, you can change the password for sudo and make your system secure from any malicious activity time and again.

How to Reset the Password for sudo in Debian