← Knowledge Base
LinuxReference note1 min read · updated 2026-11-27

Users, groups and sudo

Create users, manage group membership, grant sudo and lock accounts.

usersgroupssudo
sudo adduser alice                       # interactive (Debian/Ubuntu)
sudo usermod -aG sudo alice              # add to the sudo group (-a is essential: append)
sudo usermod -aG docker alice            # allow docker without sudo (root-equivalent!)
id alice                                 # uid, gid, groups
groups
sudo passwd -l alice                     # lock the password
sudo deluser --remove-home alice
sudo visudo                              # edit sudo rules safely (checks syntax)
sudo -l                                  # what may I run

Put custom sudo rules in /etc/sudoers.d/<name> (edit with sudo visudo -f /etc/sudoers.d/<name>). Membership of the docker group is effectively root access. Disable direct root SSH login and use key-based access for normal users.