User Management
# Create a user
sudo useradd -m -s /bin/bash username
# Create user with specific home directory
sudo useradd -m -d /home/webuser -s /bin/bash webuser
# Set password
sudo passwd username
# Delete user (and home directory)
sudo userdel -r username
Group Management
# Create a group
sudo groupadd developers
# Add user to group
sudo usermod -aG developers username
# View user groups
groups username
id username
# Remove user from group
sudo gpasswd -d username developers
Important Files
/etc/passwd — user account information/etc/shadow — encrypted passwords/etc/group — group information
The sudo System
# Add user to sudo group
sudo usermod -aG sudo username
# Edit sudoers (safe way)
sudo visudo
# Allow specific command without password
username ALL=(ALL) NOPASSWD: /usr/bin/systemctl restart nginx
System vs Regular Users
- System users (UID 0-999) — for services (www-data, mysql, nobody)
- Regular users (UID 1000+) — human accounts
- Root (UID 0) — superuser with full access