The passwd command in Linux is used to change user passwords. When run without arguments, it prompts the user for their current password and then allows them to set a new one. System administrators can use sudo passwd username to reset another user’s password. The command also offers options like -d to remove a password, -l to lock an account, and -u to unlock it. Additionally, passwd can display the current password status by viewing the /etc/shadow file
Example Commands:
passwd
Enter your old password followed by your new password when prompted.
sudo passwd username
Replace username with the desired user’s login name to set a new password for them.
sudo passwd -d username
Use -d option to remove the password from an account, making it passwordless.
sudo passwd -l username
Locking an account prevents further logins until it is unlocked. Login using ssh keys may still work.
sudo passwd -u username
Use -u to unlock a previously locked user account, allowing access again.
The passwd command is an essential tool for managing user credentials and account security in Linux. Its versatile options allow both regular users and system administrators to perform various tasks, from updating passwords to locking or unlocking accounts. Proper use of passwd helps maintain a secure and controlled environment within the operating system.