Skip to content
6 min read·Lesson 6 of 10

File Permissions and Ownership

Understand Linux read/write/execute permissions, ownership, and how to use chmod and chown to control access.

Linux is a multi-user operating system. Every file and directory has an owner and an associated permission set that controls exactly who can read, modify, or execute it. This model is the foundation of Linux security — and a topic that appears frequently in cloud and DevOps certification exams.

Reading the Permission String

Run ls -l and you'll see output like this:

-rw-r--r-- 1 alice devs 2048 Apr 10 09:30 report.txt
drwxr-xr-x 2 alice devs 4096 Apr 10 09:00 scripts/

The first 10 characters break down as:

PositionMeaningExample
1File type- file, d directory, l symlink
2–4Owner permissionsrw- = read+write
5–7Group permissionsr-- = read only
8–10Others permissionsr-- = read only

Permission characters: r = read, w = write, x = execute, - = not set.

Numeric (Octal) Notation

Each permission is a bit with a value:

SymbolValue
r4
w2
x1
-0

Add the values for each group: rwx = 7, rw- = 6, r-- = 4, --- = 0.

Common modes:

  • 755rwxr-xr-x — owner full, others read+execute. Standard for scripts and directories.
  • 644rw-r--r-- — owner read+write, others read only. Standard for config files.
  • 600rw------- — owner only. Use for SSH keys and secrets.
  • 777rwxrwxrwx — everyone full access. Avoid unless absolutely necessary.

chmod — Changing Permissions

# Numeric mode
chmod 755 deploy.sh       # rwxr-xr-x
chmod 644 config.yaml     # rw-r--r--
chmod 600 ~/.ssh/id_rsa   # rw------- (required by SSH)

# Symbolic mode
chmod +x script.sh        # add execute for everyone
chmod g+w shared.txt      # add write for group
chmod o-r private.txt     # remove read from others
chmod u=rwx,g=rx,o= prog  # set explicitly

# Recursive
chmod -R 755 /var/www/html/

chown — Changing Ownership

chown alice file.txt           # change owner to alice
chown alice:devs file.txt      # change owner and group
chown -R www-data /var/www/    # recursive change (web server files)
chgrp devs project/            # change group only

Only root (or a user with sudo) can change ownership.

Special Permissions

setuid (s on owner execute)

Runs the file as its owner, not the calling user. Used for commands like passwd that need root access briefly:

ls -l /usr/bin/passwd
# -rwsr-xr-x 1 root root ... /usr/bin/passwd

sticky bit (t on others execute)

On a directory, only the file's owner can delete it, even if others have write access. Used on /tmp:

ls -ld /tmp
# drwxrwxrwt ... /tmp

umask — Default Permissions

New files inherit permissions based on the umask (permission mask). The default umask of 022 means new files get 644 and new directories get 755:

umask        # display current umask
umask 027    # set umask: new files get 640, directories get 750

Understanding permissions is critical when configuring web servers, SSH, secrets management, and containerised workloads. The next lesson covers processes — how to see what's running and how to control it.

Key Takeaways

  • Every file has three permission sets: owner (u), group (g), and others (o).
  • Permissions are read (r=4), write (w=2), execute (x=1) — add them for octal notation.
  • chmod changes permissions; chown changes owner; chgrp changes group.
  • Executable permission on a script or binary is required to run it directly.
  • Use ls -l to inspect permissions; the first 10 characters show type and permissions.

Test your knowledge

Try exam-style practice questions to reinforce what you've learned.

Practice Questions →