Change the Password in UNIX

How do I change the password in UNIX? In Unix operating system, how do I change my password?

Introduction – To modify a user’s password or your own password in UNIX-like oeprating system use the passwd command command. To safeguard your Unix user/root password, you should change your password regularly.

ADVERTISEMENTS

How to change the password in UNIX

The procedure for changing the password of root or any user is as follows:

  1. First, log in to the UNIX server using ssh or console
  2. Open a shell prompt and type the passwd command to change root or any user’s password in UNIX
  3. The actual command to change the password for root user on UNIX is sudo passwd root
  4. To change your own password on Unix run passwd

How to change the Password in UNIX

Open the terminal and then type the passwd command entering the new password, the characters entered do not display on screen, in order to avoid the password being seen by a passer-by. The passwd command prompts for the new password twice in order to detect any typing errors. The encrypted password is stored in /etc/shadow file.

In Unix, how do I change my password

In Unix, how do I change my password

UNIX Task: Change Any Users Password

Login as the root user and type the command:
# passwd userName
# passwd vivek
# passwd tom

Sample outputs:

Enter new UNIX password: 
Retype new UNIX password: 
passwd: password updated successfully

UNIX Task: Change Your Own Password

Simply type the passwd command:
$ passwd
Sample outputs:

(current) UNIX password: 
Enter new UNIX password: 
Retype new UNIX password: 
passwd: password updated successfully

UNIX Task: Change root User Password

Log in as root user and run:
# passwd

Conclusion

The passwd command changes the user’s password. If no user is specified, the user’s login name is used. For more information see the passwd command man page by typing the following passwd command:
man passwd
man 5 passwd
man 5 shadow

🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
Network Utilitiesdig host ip nmap
Package Managerapk apt
Processes Managementbg chroot disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w

ADVERTISEMENTS
2 comments… add one
  • kris Jan 2, 2013 @ 17:25

    Thanks…very useful

  • ansar Aug 23, 2016 @ 6:45

    really thank you man

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.