User Management Tips
Advanced User Management Techniques
Modifying User Accounts
## Change user's login name
sudo usermod -l newusername oldusername
## Lock/Unlock user account
sudo usermod -L username ## Lock account
sudo usermod -U username ## Unlock account
User Group Management
graph TD
A[User Group Operations] --> B[Create Group]
A --> C[Modify Group]
A --> D[Manage Group Members]
Group Management Commands
## Create a new group
sudo groupadd developers
## Add user to multiple groups
sudo usermod -aG sudo,docker johndoe
Secure User Management Practices
Security Practice |
Command/Action |
Purpose |
Password Aging |
sudo chage -M 90 username |
Force password change every 90 days |
Account Expiration |
sudo usermod -e 2024-12-31 username |
Set account expiration date |
Restrict Shell Access |
sudo usermod -s /sbin/nologin username |
Disable interactive login |
Bulk User Management
Creating Multiple Users
## Create users from a CSV file
while IFS=',' read -r username password
do
sudo useradd -m $username
echo "$username:$password" | sudo chpasswd
done < users.csv
User Deletion and Cleanup
## Remove user account
sudo userdel username
## Remove user and home directory
sudo userdel -r username
Monitoring User Activities
## List logged-in users
who
## Show recent login history
last
## Check current user sessions
w
Permissions and Access Control
graph TD
A[User Permissions] --> B[Read]
A --> C[Write]
A --> D[Execute]
B --> E[File/Directory Access]
C --> E
D --> E
Permission Management
## Change file permissions
chmod 755 filename
## Change file ownership
chown username:groupname filename
Advanced Tips
- Use configuration management tools for large-scale user management
- Implement centralized authentication (LDAP, Active Directory)
- Regularly audit user accounts and permissions
At LabEx, we emphasize continuous learning and practical application of these user management techniques to build robust system administration skills.