Skip to content
# Users & permissions

Users and groups

Create, modify and remove Linux user accounts, and manage the groups that control what they can access.

Where accounts live

Every local user is a line in /etc/passwd (username, UID, home directory, shell); group membership lives in /etc/group. You rarely edit these files directly β€” the commands below do it safely.

Creating a user

adduser (Debian/Ubuntu) is the friendly, interactive version; useradd (available everywhere) is the lower-level command scripts use.

bash
adduser alice                 # Debian/Ubuntu, interactive
useradd -m -s /bin/bash alice # portable: -m creates the home dir
passwd alice                  # set the password

Groups and membership

usermod -aG adds a user to a group without removing them from their existing ones β€” always use -aG, never -G alone, which replaces the whole group list.

bash
groups alice
usermod -aG docker alice
getent group docker   # who's in a given group

Removing a user

userdel removes the account; add -r to also delete their home directory and mail spool.

bash
userdel -r alice