SkillSprout
Chapter 1 · Lesson 4
Beginner
1 min read

Users, Groups and sudo

Overview

Linux separates identity from permissions. A user represents a person or service. A group bundles users for common access. sudo lets an authorized user run one command with another user's privileges, usually root.

Detailed Notes

Inspect the current identity

bash
whoami
id
groups
  • whoami prints the effective user name.
  • id prints UID, GID and group memberships.
  • groups prints groups for the current user.

Example output may look like:

text
uid=1000(learner) gid=1000(learner) groups=1000(learner),27(sudo)

The UID is an integer identity. The GID identifies the primary group.

The root account

Root is the privileged administrative identity. It can change system configuration and often bypass normal file permissions. Use root only for the specific action that requires it.

bash
sudo -l
sudo id

sudo -l lists allowed administrative commands. sudo id runs id as root and prints the root identity. sudo may ask for the user's password, not the root password.

Switch to a shell carefully

bash
sudo -i
exit

sudo -i starts a root login shell. exit returns to the previous shell. Avoid leaving a root shell open.

Basic account commands

bash
sudo useradd -m appuser
sudo passwd appuser
sudo usermod -aG docker appuser
id appuser
  • -m creates a home directory.
  • passwd assigns a password.
  • usermod -aG adds a group; -a means append.

Practice account commands only in a disposable VM. On a workstation, adding users or groups can affect real access.

Common Interview Questions

Finished this lesson?

0 of 25 lessons done · 0% of the course