How to Change User Password in Linux using passwd command?

How To Change Password In Linux

In this tutorial, we are going to discuss how to change the user password in Linux. The instructions given below can work on any Linux distribution. The passwd command is used to update or change the user’s authentication token.

There are two types of users; normal users, and the root user. The normal user can only change his account password but superuser i.e. root can change the password of itself as well as of any user account present in the Linux operating system.

Let’s discuss the guidelines to create a strong password.

If you want to create a strong password then it should be of 16 characters. It indicates that your password has good strength. Have at least one special character, one uppercase, and numbers too, to generate a strong password. It’s very easy to hack into systems using easy passwords. So make sure you have a password that’s at least difficult enough to deter hackers from trying.

Let’s discuss the command used to change the password.

Change the User Password in Linux Using passwd Command

The passwd command is used without any arguments to change the password in Linux for any currently logged-in user.

$ passwd
Passwd command to change the password in Linux

Note: Linux has a feature to hide the password. You wouldn’t see any letter or number since it is hidden.

Change Another User Password

This authorization is only given to superuser i.e. root. Only the root user or other users with sudo privileges can change the password in Linux for other accounts.

The syntax is as follows:

$ passwd [username]
$ sudo passwd [username]

The output will be:

Enter new password:
Retype new password:

View a List of All the Users in the System

Linux stores the details of the users, their default home directories and their default shell in a file called /etc/passwd.

You can open the file with the below command:

$ cat /etc/passwd
Cat Passwd
Cat Passwd

List All User Accounts

We can use grep command to list all the user accounts. Grep command is used to find the word stated in the condition.

The syntax is as follows:

$ grep [username] /etc/passwd


In this tutorial, we’ve gone over how to change the user password in Linux. We hope that you now know how to use the command efficiently. If you have any questions, do let us know in the comments.