🚧 Under construction — VoTechWorks is being built. A free tech program — complimentary, as our commitment to get America working.
voTechWorksGrade 13 · a vocational technology learning center, by urbanicity
newSchoolWorks.com › VoTechWorks › Technology & Design › Web & Software Development › Linux/Bash for Web & Software Development › Lesson 3
TEC-WEB46-06 · Lesson 3 · 16 clock hours · lab

Users, Groups, and File Permissions

Objective. Students will create users and groups, assign appropriate file permissions using symbolic and octal notation, and apply the least-privilege principle to a sample web project directory.

⚠ Pending professional review

This lesson, its worked examples and its practice questions has not yet been verified by an industry-certified professional or by a certification or approval body. It is a study draft and may contain errors. Do not use it as instructions for work on a job site or on live equipment. Always follow your instructor, your supervising professional, and current official references and regulations.

VoTechWorks program approval and accreditation are still in progress. Credentials are issued only by the certifying bodies named in each program, after their own exams.

Users, Groups, and File Permissions in Linux

Linux is a multi-user operating system, meaning many people can log in and work on the same machine at the same time. To keep one user's files safe from another — and to protect system files from accidental or malicious changes — Linux uses a permission model built around three concepts: users, groups, and permission bits. Understanding this model is essential for every web and software developer who deploys code on a Linux server.

Users and Groups

Every file and directory on a Linux system is owned by exactly one user (the owner) and exactly one group. When you create a file, Linux assigns your username as the owner and your primary group as the group.

System administrators create new users with `useradd` and set passwords with `passwd`. Users are collected into groups with `groupadd` and `usermod`. For example:

```bash

sudo groupadd webteam

sudo useradd -m -G webteam alice

sudo useradd -m -G webteam bob

```

This creates a group called `webteam` and two users, alice and bob, who belong to it. The `-G` flag adds each user to the `webteam` group without changing their primary group.

To change the owner or group of an existing file or directory, use `chown`:

```bash

sudo chown alice:webteam /var/www/webteam

```

This sets the owner to alice and the group to webteam.

Reading Permission Bits

Run `ls -l` and you will see output like this:

```

-rwxr-x--- 1 alice webteam 4096 Jun 1 10:00 deploy.sh

```

The first ten characters are the permission string. The first character indicates the file type (`-` for regular file, `d` for directory, `l` for symbolic link). The next nine characters are three groups of three:

| Position | Who | Bits |

|----------|-----|------|

| 2-4 | Owner (user) | rwx |

| 5-7 | Group | r-x |

| 8-10 | Others (world) | --- |

Each position can hold `r` (read), `w` (write), or `x` (execute), or `-` if that permission is not set.

Symbolic and Octal Notation

`chmod` changes permission bits. You can write permissions two ways.

Symbolic notation uses letters and operators:

```bash

chmod g+w file.txt # add write for group

chmod o-rwx config.php # remove all permissions for others

chmod u=rw,g=r,o= data.csv # set exact permissions

```

Octal notation expresses each group of three bits as a single digit (0–7). Read = 4, write = 2, execute = 1. Add the values together:

| Octal | Binary | Permissions |

|-------|--------|-------------|

| 7 | 111 | rwx |

| 6 | 110 | rw- |

| 5 | 101 | r-x |

| 4 | 100 | r-- |

| 0 | 000 | --- |

Example: `chmod 750 deploy.sh` means owner=rwx (7), group=r-x (5), others=none (0).

The Sticky Bit

On a shared directory, any user with write permission could delete another user's files. The sticky bit prevents this: only the file's owner (or root) can delete it, even if others have write access to the directory. Set it with:

```bash

sudo chmod 1775 /var/www/webteam

sudo chmod +t /var/www/webteam

```

When `ls -l` shows a `t` at the end of the permission string (e.g., `drwxrwxr-t`), the sticky bit is active.

The Least-Privilege Principle

The least-privilege principle means giving every user, process, and file exactly the permissions needed to do its job — and nothing more. Applied to a web project:

OWASP (the Open Web Application Security Project) lists insecure file permissions as a common contributing factor to web application compromise. World-writable configuration files are especially dangerous because an attacker who gains any local access can overwrite them.

Safety and Best Practices

While Linux administration does not involve physical electrical hazards in the same way as electrical trades, there are important professional safety habits:

Setting a Shared Web Directory

A common pattern for a development team is a shared directory where all team members can read and write files, but each file is protected from deletion by others:

```bash

sudo mkdir -p /var/www/webteam

sudo chown root:webteam /var/www/webteam

sudo chmod 2775 /var/www/webteam # setgid + rwxrwxr-x

```

The setgid bit (the `2` in `2775`) causes new files created inside the directory to inherit the group `webteam` automatically, so all team members can access them without manual `chown` every time.

Key terms8

Permission bitsThe nine (or more) flags stored with every Linux file that control who can read (r), write (w), or execute (x) it, divided into owner, group, and others categories.
Octal notationA way to express Linux permission sets as three digits (0–7), where read=4, write=2, and execute=1 are added together for each of the owner, group, and others fields.
Symbolic notationA human-readable way to write chmod arguments using letters (u, g, o, a) and operators (+, -, =) to add, remove, or set specific permissions.
Sticky bitA special permission on a directory that restricts file deletion so that only the file's owner or root can delete it, even if other users have write access to the directory.
Setgid bitA special permission on a directory that causes files created inside it to automatically inherit the directory's group ownership, useful for shared team directories.
Least-privilege principleA security principle stating that users, processes, and files should be granted only the minimum permissions required to perform their intended function.
chownThe Linux command used to change the user owner and/or group owner of a file or directory.
World-writableA file or directory permission state where the 'others' category has write access, meaning any user on the system can modify or delete the file — a significant security risk.

Worked examples4

1. Convert the permission string `rwxr-x---` to octal notation.
  1. Split into three groups: owner = rwx, group = r-x, others = ---.
  2. Calculate owner: r=4, w=2, x=1 → 4+2+1 = 7.
  3. Calculate group: r=4, w=0, x=1 → 4+0+1 = 5.
  4. Calculate others: r=0, w=0, x=0 → 0+0+0 = 0.
  5. Combine the three digits: 750.
Answer: 750
2. A config file currently has permissions `rw-rw-rw-` (666). Apply the least-privilege principle: the owner needs read/write, the group needs read-only, and others need no access. Write both the octal chmod command and the symbolic chmod command.
  1. Determine target permissions: owner = rw- (6), group = r-- (4), others = --- (0).
  2. Octal: combine digits → 640. Command: chmod 640 config.php
  3. Symbolic: set each class explicitly → chmod u=rw,g=r,o= config.php
  4. Verify with ls -l; expected output shows -rw-r----- for config.php.
Answer: Octal: `chmod 640 config.php` | Symbolic: `chmod u=rw,g=r,o= config.php`
3. You want to set up `/var/www/webteam` so that: the owner (root) has full access, the webteam group has read/write/execute, others have read and execute only, and the sticky bit is set. What octal mode do you pass to chmod?
  1. Sticky bit adds 1000 in octal to the mode.
  2. Owner = rwx = 7.
  3. Group = rwx = 7.
  4. Others = r-x = 5.
  5. Base octal mode = 775.
  6. Add sticky bit: 1000 + 775 = 1775.
  7. Command: sudo chmod 1775 /var/www/webteam
Answer: 1775
4. A data file `records.dat` shows permissions `-rwxrwxrwx` (777). Identify two least-privilege violations and write the single octal chmod command that fixes both.
  1. Violation 1: others have full write access (world-writable) — a security risk.
  2. Violation 2: the execute bit is set for all classes, but a data file does not need to be executed.
  3. Target: owner reads and writes (rw-=6), group reads only (r--=4), others have no access (---=0).
  4. Octal: 640.
  5. Command: chmod 640 records.dat
Answer: `chmod 640 records.dat` removes the unnecessary execute bit and eliminates world-write access.
In class: Instructor demo: create a 'webteam' group, add two users, set a shared /var/www/webteam directory with group ownership and sticky bit; students replicate step-by-step on their own VMs. · Permission audit exercise: students receive a directory with intentionally over-permissive files (world-writable configs, executable data files) and must identify and correct each issue using chmod and chown, recording before/after output from 'ls -l'. · Scenario debrief: class reviews OWASP guidance on insecure file permissions and maps each chmod correction made during the audit to a security rationale.
Materials: Student VMs, chmod/chown man pages, OWASP File Permission guidance (owasp.org), lab log
Check: Instructor inspects final permission state of each VM using a checklist; all nine checklist items (correct owner, group, mode for three files) must be correct — pass requires 8/9.

Practice check8

Answer each question, then check it. Nothing is recorded; this is your own practice.

CompTIA Linux+ — File Permissions and Ownership
1. A file has the permission string `-rwxr-x---`. Which octal mode correctly represents these permissions?
CompTIA Linux+ — User and Group Management
2. Which command adds a user named `carol` to an existing group called `webteam` without changing carol's primary group?
CompTIA Linux+ — Special Permissions
3. What is the primary purpose of the sticky bit when applied to a shared directory?
CompTIA Linux+ — Security and File Permissions
4. A web configuration file contains database credentials. According to the least-privilege principle, which permission mode is most appropriate?
CompTIA Linux+ — File Permissions and Ownership
5. After running `chmod o-rwx /var/www/webteam/index.php`, which class of users loses all access to that file?
CompTIA Linux+ — File Permissions and Ownership
6. Which command changes the group owner of `/var/www/webteam` to `webteam` while keeping the current user owner unchanged?
CompTIA Linux+ — Security and File Permissions
7. Which OWASP-recognized risk is directly created by leaving a configuration file world-writable on a web server?
CompTIA ITF+ — Operating System Basics
8. What is the correct IT Fundamentals (ITF+) description of what a 'group' represents in a Linux user account system?
Record this lesson on my transcript. Sign in with your key and enrollment email to record lessons (enroll free if you have no key). This page stays open to read and practise.