Linux Users & Groups Management
Manage Linux user accounts, groups, /etc/passwd, /etc/shadow, sudo privileges, and security best practices.
Overview
Linux is a multi-user operating system where access rights and process privileges are segregated by User IDs (UID) and Group IDs (GID).
1. Creating Users and Groups
# Create a new user with home directory and bash shell
sudo useradd -m -s /bin/bash deployer
# Set or change user password
sudo passwd deployer
# Create a new group
sudo groupadd docker_users
# Add user to a secondary group
sudo usermod -aG sudo,docker_users deployer2. Managing sudo Privileges
The sudo (Superuser Do) command allows authorized users to execute commands with root administrative privileges without logging in directly as root.
Granting a user sudo access on Ubuntu/Debian:
sudo usermod -aG sudo aliceEditing the Sudoers File (visudo)
Always use visudo to edit /etc/sudoers because it validates syntax before saving:
sudo visudoExample passwordless sudo rule for deployment bots:
deployer ALL=(ALL) NOPASSWD: /usr/bin/systemctl restart nginx3. Important User Files
/etc/passwd: World-readable database of all local user accounts (username:x:UID:GID:comment:home:shell)./etc/shadow: Strictly protected file containing salted cryptographic password hashes (readable only by root)./etc/group: List of all system groups and their respective members.
4. Deleting Users
# Delete user while removing their home directory and mail spool
sudo userdel -r old_userLinux File Permissions & chmod / chown
Master Linux permissions, read-write-execute (rwx) bits, octal values (755, 644, 600), chmod, chown, and file ownership.
Linux Process Management & Signals
Monitor and manage Linux processes, PID lifecycles, background execution, and sending termination signals (kill, SIGTERM, SIGKILL).