Users and Groups Explained

LinuxBeginner
Practice Now

Introduction

In this lab, you will learn how to find out "who" is on your Linux system.

Imagine an apartment complex:

  • Users: Tenants.
  • Groups: Access lists (Gym Group, Pool Group).

The system keeps a "Master Directory" of everyone. In this lab, we will open that directory.

Linux inherited a strong multi-user design from Unix. Even if you are the only visible person using a small lab system, the operating system still thinks in terms of accounts, groups, ownership, and controlled access.

View User List (/etc/passwd)

The "Master Directory" of users is /etc/passwd.

Think of this file like a spreadsheet. Columns are separated by colons :.

Historically, /etc/passwd really was one of the central account databases on Unix-like systems. Modern systems handle passwords more securely than older ones did, but the account record structure is still a foundational part of Linux identity management.

View the file:

cat /etc/passwd

Output example:

root:x:0:0:root:/root:/bin/bash
labex:x:5000:5000::/home/labex:/usr/bin/zsh
...

Let's break down labex:x:5000:5000::/home/labex:/usr/bin/zsh:

  1. Username: labex
  2. Password: x (stored elsewhere)
  3. User ID (UID): 5000
  4. Group ID (GID): 5000
  5. Info: (Empty)
  6. Home: /home/labex
  7. Shell: /usr/bin/zsh

These fields connect directly to later topics in the course: identity, primary group membership, home directories, and which shell starts after login.

Identify Root User (UID 0)

The root user is the Building Manager. They have keys to everything.

Find the root entry:

grep "^root" /etc/passwd

Output:

root:x:0:0:root:/root:/bin/bash

The UID (3rd field) is 0. In Linux, UID 0 means unlimited power.

That is why Linux permissions are usually discussed in terms of numeric identities as well as names. Names are convenient for humans, but internally the system pays very close attention to IDs.

Identify Your User

Find your own entry (labex):

grep "^labex" /etc/passwd

Output:

labex:x:5000:5000::/home/labex:/usr/bin/zsh

Your UID is 5000.

Your Home Directory is /home/labex.

Check Groups (id)

/etc/passwd only lists your primary group. To see all your "access passes", use id.

id

Output:

uid=5000(labex) gid=5000(labex) groups=5000(labex),27(sudo)...

This is your ID card:

  • uid: Current user.
  • gid: Primary group.
  • groups: All group memberships.

You are in the sudo group (ID 27). This allows you to act as root!

Group membership is one of the main ways Linux manages shared access. Instead of granting permissions one user at a time for everything, the system can assign users to groups and then apply rules to those groups.

Summary

In this lab, you explored the "Who's Who" of your Linux system. You learned:

  • Users are defined in the /etc/passwd file.
  • UID 0 belongs to root, the system administrator (Building Manager).
  • UID 5000 is assigned to your user account in this system.
  • Groups control access to shared resources.
  • The id command shows your full identity, including which groups acting as "keys" you hold.

Understanding these identities is crucial because every permission in Linux—who can read a file or run a program—is based on these IDs.