Whether you are using a Ubuntu system or any other computer, we recommend that users change their passwords regularly. Updating your password prevents hackers or malicious people from getting into your machine and stealing your personal information. But whenever you are changing your password, make sure to use a unique one each time. You can change passwords in Ubuntu system with the help of your command-line interface. 

But other than that, you can also change your password with Sudo privileges if you are a root user. In this article, we are going to talk about how you can change the password of your Ubuntu system using different methods. So, keep reading the post, and you can ask us if you have any queries about the Ubuntu password.

How to Change password in Ubuntu Using Command-Line?

All Linux distributions, including Ubuntu, allow the user to change the password of a user account with the passwd command. Changing your user account password with the passwd command is also easy and doesn’t require using any other option. Type the command on your command prompt window:

Passwd

After you type the command, a prompt will appear where they will ask you to enter your current password. Make sure to provide the correct password because only after that your system will ask you to enter a new password and confirm it. Here is how the output might appear:

Changing password for linuxize.
(current) UNIX password:
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully

But your password won’t show on the screen even when you enter it. And after you change your password, you will have to use the new one when you log in to your computer next time.

But this is how you change the password of your user account from that account. There can be a requirement to change another user account's password from your current user account. Let’s see how to do that.

Changing Another User’s Password from Another User Account

If you want to change another user’s password, then you have to log in to your computer using the sudo privilege. Sudo privileges allow one user to change or modify another user’s password on Ubuntu.

You can run the passwd command along with the username of the other account to be able to change the password. For instance, if the username is opex, then run the command on your Ubuntu’s command-line interface.

sudo passwd opex

Then a command box will appear where you must provide a new password and confirm the same. The output will be like this:

Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully

But without the command line, you can still change the password for your Ubuntu system. Follow the other methods demonstrated below.

Changing User Password Via GUI

If you are using the Graphical User Interface of Ubuntu, you can change the password from the Account Details settings window. Here is how you can do it:

Step 1: Go to Settings or System Settings

Step 2: Search for Details or Account Details and click on the option

Step 3: Next, you will find a user tab where the current user accounts and the details will be portrayed. You will see the password section in the Details option as well.

Step 4: Click on Password, and a pop-up window will come up

Step 5: Here, you can change your password, but you will have to enter your current password first to be able to change it.

Step 6: Provide your existing and new password and click on Change to save it.

You can use the password from Graphical User Interface or Command Line Interface, which we also know as terminal. The following section will educate you on how to change a root password in Ubuntu

How to Change Root Password in Ubuntu and Regular Password?

You can use the ssh command to change the Ubuntu password for a remote server. But you can change the root password of your Ubuntu system from the terminal window. Here is the command for SSH:

ssh user@ubuntu-server-ip

ssh opex@ubuntu-webserver-1

Change the name Opex with your Ubuntu username. Type sudo -i in the command prompt and hit the Enter key. Then enter the current user password and press Enter again.

Then type the NA command. After that, press Enter to change the password for a root user. This command on your terminal can help you change the Ubuntu root password:

sudo passwd

If you want to change the password for a regular user (Ubuntu change user password) and not root, type the following command to change your password and replace the username with your own Ubuntu username.

sudo passwd {userNameHere}
sudo passwd opex## <-- change password for opex##
sudo passwd cactus## <-- change password for cactus##

Sometimes users just want to delete a password and not change them. If you, too, want to do that on your Ubuntu computer, follow the process below.

How to Delete a User Password?

Please note that you won’t be able to log in to your computer if your Ubuntu password is deleted or even expired. Hence, when you are deleting a user password on Ubuntu, you are doing it at your own risk.

This command will remove the password for the account named opex. Just replace the username opex with your own.

sudo passwd -d opex

## OR ##

sudo passwd --delete cactus

A confirmation message will be shown as the following:

passwd: password expiry information changed.

You then have to set up a new password after deleting the previous one; otherwise, you wouldn’t be able to log in to your Linux PC. Run the following command to set up a new password after deleting it:

sudo passwd -d Opex

However, you can also force expire the password for your account from your terminal window with this command:

sudo passwd -e Cactus

sudo passwd --expire Cactus 

Always remember to replace the username with your own Ubuntu username. Forcing the password to expire will force the user that is logging in with the same password to reset their credentials when you use the -e/--expire option. Here is the message that your user will see when he tries to log in with the expired password:

Account or password is expired, reset your password and try again
New password:
Retype new password:

And they have to put in a new password to be able to log in to their account.

Conclusion

Alternatively, you can lock a specific user from accessing your Ubuntu PC using their username like this: sudo passwd -l {username}

sudo passwd -l opex. And to unlock it, use sudo passwd -u {username}

sudo passwd -u opex. This tutorial has taught you how to change passwords in Ubuntu through the terminal, GUI, and for Root and regular users. In case you need more help, drop us a comment below.

People also read: