Linux Labs

Users, permissions, and processes / Stage 7 of 13

Managing group membership

Not running Starting usually ~20 s
Leave the lesson

Step 3 of 6 · on a machine · 5 min

Add without losing anything

To add a group to the ones already assigned, you add the -a option to -G. The old list stays, and the new group goes on the end.

bash
sudo usermod -aG group user

Without -a, the same command takes away every supplementary group that is not in the list. The mistake is silent: usermod prints nothing either way. That is why you look at id user before and after.

Warning

A group is granted for a task: a list copied from a colleague easily gives too much. sudo gives administrator rights, and adm gives reading of system logs: the nginx logs in /var/log/nginx belong to the adm group.

Exercise · do it

Add a group without losses

Add labmember to the lab-writers group. The lab-readers group and the primary group labmember must stay.

Sign in and start The machine is available after signing in

Goals · 0 of 2

  • Add labmember to lab-writers not done yet
  • Keep lab-readers and the primary group not done yet

Step goals

0 of 2
  • Add labmember to lab-writers — not done yet
  • Keep lab-readers and the primary group — not done yet
Ubuntu 24.04

Step goals

0 of 2
  • Add labmember to lab-writers — not done yet
  • Keep lab-readers and the primary group — not done yet
Loading…