User Management Skills
User Creation and Modification
Adding New Users
## Create a new user
sudo adduser username
## Create user with specific home directory
sudo adduser --home /custom/home/path username
User Modification Commands
## Modify user properties
sudo usermod -c "Full Name" username
sudo usermod -s /bin/bash username
User Management Workflow
graph TD
A[User Management] --> B{Action Type}
B --> |Create| C[adduser]
B --> |Modify| D[usermod]
B --> |Delete| E[userdel]
B --> |Password| F[passwd]
User Account Management
User Account States
Command |
Purpose |
Options |
passwd |
Password management |
-l (lock), -u (unlock) |
chage |
Password aging |
-M (max days), -m (min days) |
Group Management Skills
Group Creation and Modification
## Create a new group
sudo groupadd groupname
## Add user to multiple groups
sudo usermod -aG group1,group2 username
Advanced User Management
Bulk User Management
## Create multiple users from a file
while IFS=: read -r username password
do
sudo adduser --disabled-password --gecos "" "$username"
echo "$username:$password" | sudo chpasswd
done < users.txt
Permission and Access Control
Managing User Permissions
## Change file ownership
sudo chown username:groupname filename
## Modify file permissions
sudo chmod 755 filename
Security Best Practices
- Use strong password policies
- Implement least privilege principle
- Regularly audit user accounts
- Use sudo for administrative tasks
LabEx Learning Environment
LabEx provides interactive scenarios to practice these user management skills safely and effectively.
Scripting User Management
Automated User Creation Script
#!/bin/bash
## Automated user creation script
USERS=("john" "sarah" "mike")
DEFAULT_SHELL="/bin/bash"
for user in "${USERS[@]}"
do
sudo adduser --disabled-password --gecos "" "$user"
sudo usermod -s "$DEFAULT_SHELL" "$user"
done
Advanced Techniques
User Account Monitoring
## Last login information
last
## Currently logged-in users
who
## User login history
lastlog
Conclusion
Mastering user management skills requires practice, understanding system principles, and maintaining a security-first approach.