On Linux systems, proper user management is the foundation of security, stability, and audit compliance. One incorrectly configured user with root access can become a vulnerability for the entire infrastructure. Therefore, a system administrator must know not only basic commands, but also groups, permissions, restrictions, and activity logging.
๐ฅ Basic user management commands
Here are the basic commands everyone should know:
Team | Purpose |
---|---|
adduser and useradd | Adding a new user |
passwd | Setting or changing a password |
usermod | Changing user parameters |
deluser and userdel | Deleting a user |
groups , id | View groups |
groupadd , groupdel , groupmod | Working with groups |
๐ก๏ธ Access control: rights, groups and sudo
๐ File and directory permissions
Linux uses three categories of permissions: owner, group and others. Each of them can have permissions to:
- r โ read
- w โ write
- x โ execute
Example:
-rwxr-xr-- 1 user group 1234 Apr 5 10:00 file.txt
| ๐ Use chmod, chown, chgrp to manage permissions and owners.
๐ Sudo and groups
- Add user to sudo group:
usermod -aG sudo username
- Check who has sudo access:
getent group sudo

๐ Managing home directories and shells
- The home directory is created by default, but can be set manually:
useradd -m -d /home/new_path username
- The default shell can be set like this:
๐ง Audit and security logic
To avoid audit failure and simplify control:
โ
Disable unused accounts
โ
Regularly check groups and sudo rights
โ
Set up automatic removal of temporary users
โ
Enable logging of logins and sudo usage
sudo log file:
/var/log/auth.log
๐ Automation with Ansible (optional)
Simple playbook example for user creation:
- name: Add new user
hosts: all
become: true
tasks:
- name: Create user
user:
name: devops
shell: /bin/bash
groups: sudo
append: yes
Effective user management in Linux is a balance between convenience and security. Setting up shells, permissions, and group policies can prevent errors and increase transparency in your infrastructure.
๐ก Make your life easier, reduce risks, and always have a plan in case of an audit.
Leave a Reply