Users and groups are central to access control in Linux. A process normally runs with a user ID (UID) and group IDs (GIDs).

Inspect identities

whoami
id
getent passwd username
getent group developers

Create a user

sudo adduser ali
sudo usermod -aG sudo ali
groups ali

-aG appends supplementary group membership. Omitting -a can replace other supplementary group memberships.

Manage groups

sudo groupadd developers
sudo usermod -aG developers ali
getent group developers

Practice

Create labuser, create a students group and add the user to it. Verify with id labuser. Before changing users or sudo access on a production server, verify the intended access path.