Linux Tutorial
Linux File/Directory Management
Linux Packaging And Compression
Vim Text Editor
Linux Text Processing
Linux Software Installation
Linux User/User Group Management
Linux Permission Management
Linux Filesystem Management
Linux Advanced Filesystem Management
Linux System Management
Linux Backup and Recovery
Linux System Service Management
Linux System Log Management
Linux Boot Management
LAMP/LNMP Environment
SELinux Management
The passwd
command is a Linux utility for managing user passwords. It allows users to change their passwords, while administrators can update, lock, or unlock user accounts. In this tutorial, we'll go over some common use cases for the passwd
command.
To change your own password, simply run the passwd
command with no arguments:
passwd
You will be prompted to enter your current password, followed by the new password, and a confirmation of the new password.
If you're an administrator (root user) or have the appropriate permissions, you can change another user's password. To do this, use the passwd
command followed by the target username:
sudo passwd username
Replace "username" with the appropriate user account. You will be prompted to enter a new password and confirm it.
To lock a user account, which prevents them from logging in, use the passwd
command with the --lock
flag:
sudo passwd --lock username
Replace "username" with the user account you want to lock. This command will prepend an exclamation mark !
to the password field in the /etc/shadow
file, effectively disabling the account.
To unlock a previously locked user account, use the passwd
command with the --unlock
flag:
sudo passwd --unlock username
Replace "username" with the user account you want to unlock. This command will remove the exclamation mark !
from the password field in the /etc/shadow
file, re-enabling the account.
You can set the password expiration date for a user account with the chage
command. To force a user to change their password every 90 days, for example, run:
sudo chage -M 90 username
Replace "username" with the appropriate user account.
To display the current password aging information for a user account, use the chage
command with the -l
flag:
sudo chage -l username
Replace "username" with the appropriate user account. This command will display information such as the date the password was last changed, the password expiration date, and the number of days before the password expires.
That's it! This tutorial provided an overview of the passwd
command and some of its common use cases. For more advanced usage and a complete list of options, refer to the passwd
man page by running man passwd
in your terminal.
How to use passwd
to change user passwords:
To change your own password, simply run:
passwd
Changing user passwords in Unix-like systems with passwd
:
Use passwd
followed by the username to change another user's password:
sudo passwd username
Managing user authentication with passwd
in Linux:
passwd
is a vital tool for managing user authentication. Administrators can use it to change user passwords and set policies:
sudo passwd username
Setting password policies using passwd
in the terminal:
Password policies can be set using passwd
. For example, to set a minimum password length:
sudo passwd --minlen=8 username
Advanced options for the passwd
command in Linux:
passwd
has advanced options. For instance, expire a user's password:
sudo passwd --expire username
Force password change with passwd
in Linux:
Force users to change their password at the next login using passwd
:
sudo passwd --expire username
Changing root password using passwd
in Ubuntu/Linux:
To change the root password, use sudo passwd root
and follow the prompts:
sudo passwd root