How to change a users password in Linux

Home > Search > How-to
  by

Encrypted password

The passwd command followed by the username can be used to change the password. The new password will be encrypted.

[root@server1 ~]# passwd user1
New UNIX password: ********
Retype UNIX password: ********

 

The second field of the /etc/shadow file will contain the new, encrypted password.

[root@server1 ~]# cat /etc/shadow | grep user1
user1:$6HV7FH3HVNFH7X8DJ1MDHC8SA7J1M388E8SJSJDMD71J37A:1002:1002::/home/user1:

 

Refer to the passwd command.

 


Clear text password

The usermod command with the -p or --password option can be used to create a cleartext password.

[root@server1 ~]# usermod -p MyPassword user1

 

The second field in the /etc/passwd file will have an "x", because passwords are not stored in the /etc/passwd file.

[root@server1 ~]# cat /etc/passwd | grep user1
user1:x:1002:1002::/home/user1:

 

The second file in /etc/shadow will show either the encrypted or cleartext password.

[root@server1 ~]# cat /etc/shadow
user1:MyPassword:1002:1002::/home/user1:

 

Refer to the usermod command.



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.




Please enter in the box below so that we can be sure you are a human.




Comments