Archive · Linux

Users, Groups and sudo

Create users, give them the access they need, and avoid logging in as root.

1 min read

  • Ubuntu 18.04.2 LTS
  • sudo 1.8.21

Every process and file belongs to a user and a group. Day-to-day work should happen as a normal user, using sudo only for commands that need it.

sudo adduser deploy                 # interactive: password, home directory
sudo usermod -aG sudo deploy        # Ubuntu: members of "sudo" may use sudo
id deploy                           # uid, gid and groups
sudo passwd -l olduser              # lock an account without deleting it

On CentOS 7 the admin group is wheel, so the command is usermod -aG wheel deploy. That one difference trips up many people moving between the two.

Edit sudo rules only with sudo visudo, which checks syntax before saving. A broken sudoers file can lock you out of root. Prefer drop-in files under /etc/sudoers.d/ over editing the main file.