Command To Change Password in Unix

Can you tell me command to change a password in Unix? How do I change a password in Unix operating system like macOS desktop or FreeBSD Unix server using the command line?

Introduction: To order to protect your Unix account, you must change your password at least every three to six months. A good password includes sequences of letters, numbers, and symbols that you enter to verify your identity to a Unix system. Once your identity verified, you will be granted access to server resources. In practice, one must use a password manager. A password manager can generate a password. It might be 30 to 40 characters long. It is far more difficult for a cracker to break a 40-character long password than an eight-character password. Apart from a good password on can use 2FA too to secure his/her password further.

ADVERTISEMENTS

Say hello to the Unix passwd command

All you have to do is type the following Unix passwd command to change your password:
passwd
You must provide an old password. Once old password verified, the Unix system will ask for a new password twice. As I suggested earlier, you must choose a complex password. All Unix password is case sensitive. The above command will change the password only on the laptop or server you are currently logged in using the ssh command or terminal session.

Command To Change Password in Unix

In short, to change your own password, type:
$ passwd
Command To Change Password in Unix
To change other users password, you must know root user password. A typical option is to use the su command or sudo command to become a root user and change the Unix user password:
$ sudo passwd
The file /etc/passwd contains a list of all users on Unix system. The passwd command contains other features, as well such as locking an user account and more.

Conclusion

In this quick tutorial you learned how to I change the password in Unix operating system using the passwd command. For more info see passwd command man page by typing the following command or online here and here:
$ man passwd

🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
FirewallCentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
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
WireGuard VPNCentOS 8 Debian 10 Firewall Ubuntu 20.04

ADVERTISEMENTS
2 comments… add one
  • Raju K Mar 1, 2009 @ 7:16

    This solved my problem.

  • BSD Fan Dec 21, 2014 @ 7:16

    I googled “In Unix, how do I change my password?” and this page helped me to solve it on FreeBSD server. thanks!!!

Leave a Reply

Your email address will not be published.

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