chmodcalculator
System Architecture

Linux File Permissions Architecture

The POSIX file permission system is the foundational security layer of Linux and Unix systems. This guide explains how permissions are stored in disk inodes, how the kernel evaluates access requests, and how to compute complex permission masks.

Test Your Permissions Live

Interactive Calculator
Ready-to-run Linux command
chmod 755 filename

Permission Checkbox Matrix

Click any permission to recalculate instantly
User / Owner (u)
File creator / owner
Total:7
Group (g)
Assigned user group
Total:5
Others / Public (o)
All other system users
Total:5
4thAdvanced / Special Permissions (SUID, SGID, Sticky Bit)
Dynamic Permission Translation
Owner:Read, Write, Execute (Full access)
Group:Read, Execute
Others:Read, Execute
File vs Directory Semantics

For Files: x allows binary or script execution.
For Directories: x is the search/traverse bit, required to cd into the directory and access inner files. Without directory execute, users cannot open subdirectories even with read rights!

Quick Permission PresetsClick to apply
Copied to clipboard

1. The Inode and File Metadata

In Unix-like operating systems, a file's name is merely an entry in a directory table. The actual metadata—including ownership, size, timestamps, and permission bits—is stored inside an inode (index node).

The mode field in an inode is a 16-bit integer that stores:

  • 4 bits: File type (regular file, directory, symbolic link, socket, FIFO, character/block device).
  • 3 bits: Special permissions (SUID, SGID, Sticky Bit).
  • 9 bits: Standard read/write/execute permissions across Owner, Group, and Others.

2. Anatomy of ls -l Output

When running ls -l in a terminal, the first column displays a 10-character string:

- r w x r - x r - x 1 webadmin developers 4096 Sep 15 22:00 app.py
┬ └─┬─┘ └─┬─┘ └─┬─┘ │ │ │ │ │ │
1 2 3 4 5 6 7 8 9 10
1. File Type: - = regular file, d = directory, l = symlink.
2. Owner Triplet (rwx): Permissions granted to the owning user.
3. Group Triplet (r-x): Permissions granted to the assigned group.
4. Others Triplet (r-x): Permissions granted to all other system users.

3. How the Linux Kernel Evaluates Access

A crucial and often misunderstood rule of Linux permissions is that evaluation stops at the first match:

  1. Owner Check: If the user attempting access is the owner of the file, only the owner bits (u) are checked. If the owner does not have write permission, access is denied immediately—even if group or others have write permissions!
  2. Group Check: If the user is not the owner, but belongs to the group that owns the file, only the group bits (g) are evaluated.
  3. Others Check: If the user is neither the owner nor in the group, the others bits (o) apply.
  4. Superuser Exception: The root user (UID 0) bypasses normal read and write restrictions, though execute permission still requires at least one execute bit set on the file.

4. Understanding Umask (User Mask)

When a new file or folder is created, the system applies a umask to strip permissions from default maximum values:

Default New Directories
Max Base: 777 (rwxrwxrwx)
Umask 022 → Result: 755 (rwxr-xr-x)
Default New Regular Files
Max Base: 666 (rw-rw-rw-)
Umask 022 → Result: 644 (rw-r--r--)

To check your active shell umask, simply type umask into your terminal. A stricter umask of 027 creates directories with 750 and files with 640, preventing all public access by default.