> ## Documentation Index
> Fetch the complete documentation index at: https://notes.kodekloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Demo Working With Linux File System Permissions

> Guide to creating users and groups, assigning file ownership with chown, and managing permissions using numeric and symbolic chmod, with verification using ls -l

In this lesson you'll apply Linux file system permissions in a practical sequence: create users and groups, assign ownership, and use both numeric and symbolic forms of `chmod`. The objective is not just to run commands, but to understand how each change affects access control so you can enforce proper policies on a Linux system.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/9E2T0ocsNwD7Od8i/images/Prep-Course-Red-Hat-Certified-System-Administrator-RHCSA/Linux-Permissions/Demo-Working-With-Linux-File-System-Permissions/linux-file-system-permissions-lock.jpg?fit=max&auto=format&n=9E2T0ocsNwD7Od8i&q=85&s=7ca8bc94c141a7266df0cf3952986052" alt="The image is a dark presentation slide titled &#x22;Working With Linux File System Permissions.&#x22; It also shows a simple blue outline icon of a file with code brackets and a padlock, suggesting locked or secured files." width="1920" height="1080" data-path="images/Prep-Course-Red-Hat-Certified-System-Administrator-RHCSA/Linux-Permissions/Demo-Working-With-Linux-File-System-Permissions/linux-file-system-permissions-lock.jpg" />
</Frame>

What you'll learn

* Create users and groups, and add users to a group.
* Change ownership with `chown` (including `-R` for recursion).
* Set permissions with numeric `chmod` (e.g., `640`) and symbolic `chmod` (e.g., `g+w`, `o-rwx`).
* Verify results with `ls -l`.

<Callout icon="lightbulb" color="#1CB2FE">
  Numeric permission shorthand: 6 = read+write (rw), 4 = read (r), 2 = write (w), 1 = execute (x), 0 = no permissions. Example: `640` → owner `rw` (6), group `r` (4), others `-` (0).
</Callout>

Prerequisites

* You will run the commands as root (prompt shown as `root@control:/#`). If you are not root, prefix admin commands with `sudo`.
* Basic familiarity with the shell and `ls -l` output is helpful.

Step-by-step demo
Run the following commands in order. Explanations follow each section.

Create users and a group, then add users to the group:

```bash theme={null}
root@control:/home# useradd dev1
root@control:/home# useradd dev2
root@control:/home# useradd manager
root@control:/home# groupadd devteam
root@control:/home# usermod -aG devteam dev1
root@control:/home# usermod -aG devteam dev2
```

* We created three accounts: `dev1`, `dev2`, and `manager`.
* We created a shared group `devteam` and appended `dev1` and `dev2` to it using `usermod -aG`, which preserves existing group memberships.

Create a project directory and a config file, then set ownership:

```bash theme={null}
root@control:/# cd /
root@control:/# mkdir project
root@control:/# touch /project/app.conf
root@control:/# chown dev1:devteam /project/app.conf
root@control:/# ls -l /project
total 0
-rw-r--r-- 1 dev1 devteam 0 Apr 20 16:03 app.conf
```

* `chown dev1:devteam /project/app.conf` assigns the file owner to `dev1` and group to `devteam`.
* `ls -l` confirms owner and group: `dev1 devteam`.

Set permissions so owner can read/write, group can read, others have none (numeric `chmod 640`):

```bash theme={null}
root@control:/# chmod 640 /project/app.conf
root@control:/# ls -l /project
total 0
-rw-r----- 1 dev1 devteam 0 Apr 20 16:03 app.conf
```

* `chmod 640` sets owner = `rw` (6), group = `r` (4), others = `-` (0). The `ls -l` permission display shows `-rw-r-----`.

Create a second file and apply ownership recursively:

```bash theme={null}
root@control:/# touch /project/app2.conf
root@control:/# ls -l /project
total 0
-rw-r----- 1 dev1 devteam 0 Apr 20 16:03 app.conf
-rw-r--r-- 1 root root    0 Apr 20 16:06 app2.conf

root@control:/# chown -R dev1:devteam /project
root@control:/# ls -l /project
total 0
-rw-r----- 1 dev1 devteam 0 Apr 20 16:03 app.conf
-rw-r--r-- 1 dev1 devteam 0 Apr 20 16:06 app2.conf
```

* When `app2.conf` was created, defaults gave it owner `root:root`.
* `chown -R dev1:devteam /project` recursively changes owner and group for the directory and its contents to `dev1:devteam`.

Add group write permission to `/project/app.conf` using symbolic `chmod`:

```bash theme={null}
root@control:/# chmod g+w /project/app.conf
root@control:/# ls -l /project
total 0
-rw-rw---- 1 dev1 devteam 0 Apr 20 16:03 app.conf
-rw-r--r-- 1 dev1 devteam 0 Apr 20 16:06 app2.conf
```

* `chmod g+w` adds write permission for the group without changing owner or other bits.
* `app.conf` now shows `-rw-rw----` (owner `rw`, group `rw`, others `-`) which corresponds to numeric `660`.

Remove any privileges from others explicitly:

```bash theme={null}
root@control:/# chmod o-rwx /project/app.conf
root@control:/# ls -l /project
total 0
-rw-rw---- 1 dev1 devteam 0 Apr 20 16:03 app.conf
-rw-r--r-- 1 dev1 devteam 0 Apr 20 16:06 app2.conf
root@control:/#
```

* `chmod o-rwx` removes read, write, and execute bits from others. If others already had no permissions, the state remains unchanged.

Quick reference — common numeric values

| Numeric | Symbolic | Meaning |
| -: | - | - |
| `700` | `rwx------` | Owner full, group/others none |
| `750` | `rwxr-x---` | Owner rwx, group rx, others none |
| `640` | `rw-r-----` | Owner rw, group r, others none |
| `660` | `rw-rw----` | Owner rw, group rw, others none |
| `644` | `rw-r--r--` | Owner rw, group r, others r |

Commands summary

| Command | Purpose |
| - | - |
| `useradd <user>` | Create a new user account |
| `groupadd <group>` | Create a new group |
| `usermod -aG <group> <user>` | Add `<user>` to supplementary `<group>` without removing other groups |
| `chown user:group <file>` | Change owner and group of a file |
| `chown -R user:group <dir>` | Recursively change owner/group for a directory and its contents |
| `chmod <mode> <file>` | Set file mode using numeric (e.g., `640`) or symbolic (e.g., `g+w`) forms |
| `ls -l` | List files with owner/group and permission bits |

Best practices and warnings

<Callout icon="warning" color="#FF6B6B">
  Use `chown -R` and recursive `chmod` with care — they can change ownership/permissions for many files at once. Double-check the target path to avoid inadvertently changing system or unrelated files.
</Callout>

Further reading

* `man chmod` — [https://man7.org/linux/man-pages/man1/chmod.1.html](https://man7.org/linux/man-pages/man1/chmod.1.html)
* `man chown` — [https://man7.org/linux/man-pages/man1/chown.1.html](https://man7.org/linux/man-pages/man1/chown.1.html)
* Practical guide on Linux file permissions — [https://www.digitalocean.com/community/tutorials/understanding-linux-file-permissions](https://www.digitalocean.com/community/tutorials/understanding-linux-file-permissions)

Summary

* Created users and a shared group, then added users to that group.
* Created files, set ownership with `chown` and `chown -R`.
* Used numeric `chmod` (e.g., `640`) to explicitly set owner/group/others bits.
* Used symbolic `chmod` (`g+w`, `o-rwx`) to tweak permission classes without altering other bits.
* Verified each step with `ls -l` to confirm ownership and permissions.

<CardGroup>
  <Card title="Watch Video" icon="video" cta="Learn more" href="https://learn.kodekloud.com/user/courses/red-hat-certified-system-administrator-rhcsa/module/3c103226-2d1c-4dd2-ac12-db543617e7c2/lesson/0aa0a493-4305-4fa6-a1b5-bff7645bd227" />
</CardGroup>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.