How to Change the Password for a User in Linux


In this article, we show how to change the password of a user in Linux.

So when you first start a new server project, you have a root user only and this root user is given a random password at first. You use this random password generated for you by the hosting company just to gain initial access to the remote server. However, most people want their own custom password, not the one generated by the hosting company. So you need to change the password.

And other times, you just simply want to change the existing password to something else.

So how do we do this in linux?

So the first thing is you just log in to the user for which you want to change the password with the current existing password. Then, once you are logged in to this user, you can change the password by specifying, passwd

Again, when you are logged into the user whose password you want to change, specify the following below.

After this statement, passwd, then you will be prompted to fill in the new password for this user. You will be asked a second time for the password for confirmation.

Below is an example of changing the password for the root user in linux in the command terminal. Changing the password of a user in linux

So we specify a password change with the statement, passwd

This is shown in the example below.

You can see immediately after we have this line, we are prompted to enter the new password for this user. We do so once again to confirm the password, to make sure the correct one is entered.

And now the next time when you log into the user's account, you do so with the new password.

And this is how to change the password of a user in linux.

Related Resources

How to Randomly Select From or Shuffle a List in Python

HTML Comment Box is loading comments...