Skip to content

👤 Users and Permissions

Understanding how Linux manages users, groups, ownership and access control.


Table of Contents

  1. Why Users Exist
  2. Users
  3. Groups
  4. Root User
  5. Sudo
  6. Authentication vs Authorization
  7. Ownership
  8. Permission Model
  9. Read, Write and Execute
  10. Viewing Permissions
  11. chmod
  12. Numeric Permissions
  13. Symbolic Permissions
  14. chown
  15. Useful User Commands
  16. Useful Group Commands
  17. Security Principles
  18. Mental Model

1ī¸âƒŖ Why Users Exist

Linux was designed as a multi-user operating system.

Without users and permissions:

Everyone could access everything

which would be a major security risk.

Users allow Linux to identify:

  • who is performing an action
  • who owns a file
  • who can access a resource

2ī¸âƒŖ Users

A user represents an identity inside Linux.

Examples:

sara
student
admin

Users can:

  • own files
  • run processes
  • belong to groups
  • access resources

Every action performed on Linux is associated with a user.


Viewing Current User

whoami

Displays the current logged-in user.

Example:

sara

Viewing User Information

id

Displays:

  • User ID (UID)
  • Group ID (GID)
  • Group memberships

Example:

uid=1000(sara)
gid=1000(sara)
groups=1000(sara),27(sudo)

3ī¸âƒŖ Groups

Groups allow permissions to be assigned to multiple users simultaneously.

Instead of managing:

Sara
John
Maria

individually, Linux can use:

developers

and assign permissions to the group.


Viewing Groups

groups

Displays groups associated with the current user.


Creating Groups

groupadd developers

Creates a new group.


Adding Users to Groups

usermod -aG developers sara

Adds a user to a group.


Why Groups Matter

Groups simplify permission management.

Instead of assigning permissions individually, permissions can be assigned once to a group.


4ī¸âƒŖ Root User

Root is the administrator account.

Root has unrestricted access.

Root can:

  • install software
  • create users
  • remove users
  • modify system configuration
  • change permissions

Think of root as:

The owner of the entire system

5ī¸âƒŖ Sudo

Instead of logging directly as root, Linux commonly uses:

sudo command

Example:

sudo apt update

Sudo allows:

Temporary administrator privileges

Benefits:

  • accountability
  • logging
  • better security

6ī¸âƒŖ Authentication vs Authorization

These concepts are different.


Authentication

Answers:

Who are you?

Examples:

  • Passwords
  • SSH Keys

Authorization

Answers:

What are you allowed to do?

Examples:

  • Read files
  • Modify files
  • Install software

Authentication identifies.

Authorization grants permissions.


7ī¸âƒŖ Ownership

Every file has:

  • an owner
  • a group owner

Example:

Owner: sara
Group: developers

Ownership determines who controls the resource.


Viewing Ownership

ls -l

Example:

-rw-r--r-- 1 sara developers file.txt

8ī¸âƒŖ Permission Model

Linux uses three permission categories.

Owner
Group
Others

Each category receives different permissions.


9ī¸âƒŖ Read, Write and Execute

Linux permissions are built around three actions.


Read (r)

Allows viewing content.

Examples:

  • open files
  • view directories

Write (w)

Allows modifications.

Examples:

  • edit files
  • create files
  • delete files

Execute (x)

Allows execution.

Examples:

  • run programs
  • run shell scripts

🔟 Viewing Permissions

Example:

-rwxr-xr--

Breakdown:

rwx | r-x | r--

Owner | Group | Others


Meaning:

Owner:

  • Read
  • Write
  • Execute

Group:

  • Read
  • Execute

Others:

  • Read

1ī¸âƒŖ1ī¸âƒŖ chmod

chmod means:

Change Mode

Used to modify permissions.


Example:

chmod 755 script.sh

Changes file permissions.


Making a script executable:

chmod +x script.sh

One of the most common uses of chmod.


Removing write permission:

chmod -w file.txt

1ī¸âƒŖ2ī¸âƒŖ Numeric Permissions

Linux can represent permissions numerically.

Common values:

755
744
700
644

Relationship:

r = 4
w = 2
x = 1

Examples:

7 = rwx
6 = rw-
5 = r-x
4 = r--

Example:

chmod 644 file.txt

1ī¸âƒŖ3ī¸âƒŖ Symbolic Permissions

Instead of numbers, permissions can be modified symbolically.

Examples:

chmod +x script.sh
chmod -w file.txt
chmod g+w file.txt

Symbolic mode focuses on:

Adding or removing permissions

1ī¸âƒŖ4ī¸âƒŖ chown

chown means:

Change Owner

Used to transfer ownership.


Example:

chown sara file.txt

Changes the owner.


Changing owner and group:

chown sara:developers file.txt

Ownership and permissions work together.


1ī¸âƒŖ5ī¸âƒŖ Useful User Commands

Display current user:

whoami

Display user information:

id

Create a user:

useradd username

Delete a user:

userdel username

1ī¸âƒŖ6ī¸âƒŖ Useful Group Commands

Display groups:

groups

Create group:

groupadd developers

Modify group membership:

usermod -aG developers sara

Delete group:

groupdel developers

1ī¸âƒŖ7ī¸âƒŖ Security Principles

Linux permissions follow important security concepts.


Least Privilege

Give users only the permissions they need.


Separation of Responsibilities

Different users perform different tasks.


Access Control

Protect resources according to their importance.


Permissions are one of Linux's primary security mechanisms.


1ī¸âƒŖ8ī¸âƒŖ Mental Model

Imagine an office building.


Users are:

Employees

Groups are:

Departments

Files are:

Documents

Permissions are:

Access badges

Root is:

The building owner

Final Mental Image

Users
    ↓
Groups
    ↓
Permissions
    ↓
Security

Linux uses this hierarchy to control who can access what.