
Linux user management is a fundamental aspect of system administration, ensuring secure and organized access to resources. This tutorial covers essential concepts and commands for effective user administration on Linux.
1. Creating Users:
To create a new user, use the useradd command:
sudo useradd username
2. Setting Passwords:
Set passwords for users with passwd:
sudo passwd username
3. Modifying User Properties:
Use usermod to modify user properties:
sudo usermod -aG groupname username
4. Deleting Users:
Remove users with userdel:
sudo userdel username
5. Managing Groups:
Create a new group with groupadd:
sudo groupadd groupname
Add a user to a group:
sudo usermod -aG groupname username
6. Viewing User Information:
View detailed user information with id:
id username
7. Understanding Home Directories:
Home directories are crucial for user-specific settings and data. Ensure proper permissions:
sudo chown -R username:username /home/username
8. Granting sudo Privileges:
Grant sudo privileges to a user by adding them to the sudo group:
sudo usermod -aG sudo username
9. Locking and Unlocking Accounts:
Lock an account with passwd:
sudo passwd -l username
Unlock an account:
sudo passwd -u username
10. Monitoring User Activity:
Check user login history with last:
last username
11. Security Best Practices:
Regularly audit user accounts.
Enforce strong password policies.
Monitor system logs for suspicious activity.
Limit the use of the root account.
