User Password Commands
Basic Password Management Commands
Linux provides several powerful commands for managing user passwords effectively:
Command |
Function |
Usage |
passwd |
Change user password |
passwd [username] |
chpasswd |
Update multiple user passwords |
chpasswd < userlist.txt |
passwd -l |
Lock user account |
passwd -l username |
passwd -u |
Unlock user account |
passwd -u username |
Changing User Password
## Change current user password
passwd
## Change another user's password (requires root privileges)
sudo passwd username
Password Configuration Options
graph TD
A[Password Command Options] --> B[Password Aging]
A --> C[Password Strength]
A --> D[Account Locking]
B --> E[chage Command]
C --> F[Password Complexity]
D --> G[Account Restrictions]
Advanced Password Management
Password Aging Control
## View password aging information
sudo chage -l username
## Set password expiration
sudo chage -M 90 username
Password Strength Configuration
## Install password strength checking tool
sudo apt-get install libpam-pwquality
## Configure password complexity in /etc/security/pwquality.conf
minlen=12 ## Minimum password length
dcredit=-1 ## Require at least one digit
ucredit=-1 ## Require at least one uppercase letter
User Account Password Operations
- Create new user with password
## Create user and set password
sudo useradd -m newuser
sudo passwd newuser
- Disable user password login
## Disable password authentication
sudo passwd -l username
Best Practices
- Use strong, unique passwords
- Regularly update passwords
- Implement password complexity rules
- Use multi-factor authentication when possible
At LabEx, we recommend understanding these commands to effectively manage user authentication in Linux environments.