The passwd
command in Linux is used to change user passwords. It allows users to update their own passwords or, if executed by a superuser, to change passwords for other users. This command is essential for maintaining security by ensuring that user accounts have strong, unique passwords.
The basic syntax of the passwd
command is as follows:
passwd [options] [username]
If no username is specified, the command will change the password for the currently logged-in user.
-d
: Delete the password for the specified user, allowing login without a password.-e
: Expire the password immediately, forcing the user to change it upon next login.-l
: Lock the specified user’s password, preventing them from logging in.-u
: Unlock a previously locked user account.-S
: Display the password status of the specified user.passwd
sudo passwd username
sudo passwd -d username
sudo passwd -e username
sudo passwd -l username
sudo passwd -u username
passwd -S username