How to Change Your User Password In Linux

It’s a quick and easy process to change a user password on a system using the Linux Operating System. That is, it’s straight forward if you know the commands, which might not be obvious if your background is with other operating systems such as Microsoft Windows. This article shows how to change your user password on a Linux system.

As there are many Linux distributions, with different desktop environments with can look and feel differently, this guide focuses on how to change your password from a shell prompt. The steps below will work from a shell session within a desktop session, or when connecting remotely using SSH, and will cover how to change your Linux password or reset your or another user password.

How to Change Your Linux Password

The passwd command is used to change a user password from the Linux command line. If you are in a desktop environment, you will first need to open a terminal shell application. For example, the terminal application on Ubuntu:

Alternatively, these steps will also work fine to change the password over a remote SSH connection.

Once at the shell prompt, simply type passwd to be prompted to change your own user password:

$ passwd
Changing password for user cloud_user.
Changing password for cloud_user.
(current) UNIX password:

When prompted, you will need to supply your current password, and then you will be prompted to enter your new password twice.

Note, that if there are password policies in place you may receive an error when trying to reset your password. For example, if your new password is too similar to the old one. In which case you would be prompted again to choose a new password:

New password:
BAD PASSWORD: The password is too similar to the old one
New password:

How to Reset a Linux User Password

Sometimes you may need to change another user’s password. To do so, we still need to use the passwd command, but this time it may be necessary to use the sudo command to elevate your permissions (unless you are logged in as the root user). The syntax to reset a user password is:

$ sudo passwd [username]

So, for example, to reset the password of the user1 account, you would use:

$ sudo passwd user1

And that’s it! The password change will take affect immediately.

Related posts

Mastering the Linux ifconfig Command

Docker Exec Command With Practical Examples

Debugging with Git Bisect

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Read More