How To Change User’s Password Through Terminal In Linux/Unix?


Linux or Unix is the multi-user operating system that means more than one user can use system resources simultaneously. In order to use the system resources, users are required to login to their respective user accounts.

To prevent unauthorized user access these accounts can be protected with a password. So anyone who wants to access the system resources needs a user account and password.

In this article, we will discuss to set or change the password of a user account by using a terminal.

Change the password of the current user

In the Linux password of user accounts are stored in /etc/shadow file in encrypted form. The passwd command is used to change or set the password of a user account.

Now to change the password of the current user, use the following command in your terminal-

passwd

Once you execute this command it will ask you to enter the current password, enter it. In the next lines, it will ask you to enter a new password and retype it. Now if password matches then your password will be updated successfully.

Change the password of another user

You can change the password of another user by logging into your account using the following command –

sudo passwd user_name

For example –

sudo passwd vaibhav

Once this command gets executed you will be asked to enter the new password and retype it in the next line. If the password you enter matches then you will get a message that password updated successfully.

How to change the password of the root user

To change the password of the root user, use the following command in your terminal-

sudo passwd root

or first, log in to root account and then enter the following command –

passwd

And then provide whatever information it ask to enter.

Conclusion

Now I hope the information provided here is useful to you. If you have any questions regarding this topic you can write to us in the comments below.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.