passwd Command: Tutorial & Examples
passwd command is a crucial command-line utility in Linux used for changing user passwords. It interacts with the
system's authentication files, usually located in the
/etc/shadow, where the actual password hashes are stored. It's a vital tool for
maintaining the security of a Linux system, as it allows administrators to update, create, or secure user passwords.
How does passwd work?
passwd command works by modifying the stored user password in the system. When executed, it prompts the user to
enter the new password and then retype it for confirmation. Once validated, the password is encrypted and stored in
Importance of the passwd command
passwd command is essential in maintaining the security of a Linux system. It allows system administrators to
create, change, and manage user passwords effectively. It's also the first line of defense against unauthorized access,
making it a vital tool in any Linux administrator's toolkit.
Common problems solved by passwd
One common problem that can be solved using the
passwd command is user password expiration. In some Linux
distributions, user passwords are set to expire after a certain period. When a password expires, the user can't log in
until the password is changed. The
passwd command can be used to update the expired password and allow the user to
access the system.
passwd command examples
Let's have a look at some practical examples of how to use the
Changing the current user's password:
After running the
passwdcommand, you will be prompted to enter the new password, and then retype the new password.
Changing another user's password:
As a system administrator, you can change another user's password. For instance, to change the password for user ' tom', you would use:
sudo passwd tom
Locking and unlocking a user password:
passwdcommand can also be used to lock and unlock user accounts. To lock a user account, use the
sudo passwd -l tom
And to unlock it:
sudo passwd -u tom
Typical output for these commands would be:
Changing password for tom.
Retype new password:
passwd: password updated successfully
This output confirms the password has been updated successfully.
passwd command is a powerful tool for managing user passwords on a Linux system. It allows for the creation,
change, and management of user passwords, thereby playing a vital role in system security. As a Linux user or
administrator, mastering the
passwd command is crucial for effective user management and system security.