Chmod Permissions Calculator

Calculate Linux / Unix file permissions (755, 644, 777), symbolic notation (-rwxr-xr-x), and generate terminal commands.

4.9 / 5· 148 verified ratings
•
100% Client-Side Privacy
•
Verified 2026 Engine
Loading tool engine...
Frequently Used With:UUID / GUID Generator (v4 & v1) →Cron Expression Generator & Schedule Builder →Lorem Ipsum Placeholder Text Generator →HTML Entity Encoder & Decoder →
Institutional-Grade Accuracy & Client-Side Privacy Guarantee

Unlike conventional calculator sites that send your financial numbers, payload data, or code snippets across remote web servers, Affi-Chain processes all mathematical derivations, algorithms, and data parsing 100% locally within your browser sandbox. No tracking cookies, no server-side retention, and zero transmission lag.

POSIX File System Permissions Architecture

A Chmod Calculator generates, decodes, and validates access control permissions across Unix-like operating systems (Linux, macOS, BSD, and AIX). In the POSIX (Portable Operating System Interface) filesystem architecture, every file, directory, named pipe, and socket is governed by an Inode Metadata Structure containing 12 discrete permission bits.

These bits establish access boundaries across three distinct security classes:

  1. User / Owner ($u$): The individual user account that owns the file.
  2. Group ($g$): The system user group assigned to the file (enabling team collaboration).
  3. Others / World ($o$): Every other authenticated or unauthenticated account on the operating system.
+---------------------------------------------------------------------------------------------------+
|                                  POSIX PERMISSION TRIAD MATRIX                                    |
+---------------------------------------------------------------------------------------------------+
|  USER / OWNER (u)                            GROUP (g)                        OTHERS / WORLD (o)  |
|  [ r ] [ w ] [ x ]                           [ r ] [ w ] [ x ]                [ r ] [ w ] [ x ]   |
|    4     2     1                               4     2     1                    4     2     1     |
|   Binary: 1 1 1 = 7                           Binary: 1 0 1 = 5                Binary: 1 0 1 = 5  |
+---------------------------------------------------------------------------------------------------+
                                                  |
                                                  v
+---------------------------------------------------------------------------------------------------+
|  STANDARD LINUX OCTAL NOTATION: 0755 (-rwxr-xr-x)                                                 |
|  - Owner: Read, Write, Execute (7)                                                                |
|  - Group: Read, Execute (5)                                                                       |
|  - Others: Read, Execute (5)                                                                      |
+---------------------------------------------------------------------------------------------------+

File Permissions vs. Directory Permissions

A crucial operational distinction in Unix systems is that permission bits execute completely different functions on regular files versus directories:

+---------------------------------------------------------------------------------------------------+
|                                  FILE VS. DIRECTORY PERMISSION SEMANTICS                          |
+---------------------------------------------------------------------------------------------------+
|  Bit   Numeric Value   On a Regular File                   On a Directory Folder                  |
|  ----  -------------   ----------------------------------  -------------------------------------  |
|  r     4 (2^2)         Open and read file contents         List filenames via `ls`                |
|  w     2 (2^1)         Modify, overwrite, truncate file    Create, delete, or rename child files  |
|  x     1 (2^0)         Execute file as a compiled program  Traverse directory (`cd`) or stat files|
+---------------------------------------------------------------------------------------------------+

Octal Mathematics, Bitmasks & Special Bits

Every permission triad is computed as the sum of three binary powers of two:

$$\text{Octal Digit} = (r \times 4) + (w \times 2) + (x \times 1)$$

Where each flag $r, w, x \in {0, 1}$.

Special Permission Bits: SUID, SGID, and Sticky Bit

In addition to the standard 9-bit triad, Unix systems provide three higher-order Special Bits (The 4th Octal Digit):

                      SPECIAL BITS ARCHITECTURE (4-DIGIT OCTAL)
                      
   SET USER ID (SUID = 4000):   Executes process under file OWNER's UID (e.g. /usr/bin/passwd)
   
   SET GROUP ID (SGID = 2000):  Files created inherit directory's GROUP; or executes as GID
   
   STICKY BIT (STICKY = 1000):  Only file OWNER or root can delete files (e.g. /tmp directory)
  • SUID (Octal 4000 / Symbol s in user position): When executed, the process assumes the effective privileges of the file's owner (e.g., root) rather than the user running it.
  • SGID (Octal 2000 / Symbol s in group position): In shared collaboration folders, any new file created automatically inherits the parent folder's group ownership rather than the creator's primary group.
  • Sticky Bit (Octal 1000 / Symbol t in others position): Standard on world-writable directories like /tmp (chmod 1777 /tmp). It prevents regular users from deleting, renaming, or modifying files owned by other users.

Production Code Implementation

Python: Industrial Chmod Parser, Octal Converter & Security Risk Auditor

#!/usr/bin/env python3
"""
Production POSIX Chmod Permissions Engine.
Converts between 3/4-digit Octal and 10-character Symbolic notation,
evaluates effective umask permissions, and flags dangerous security configurations.
"""

from typing import Dict, Tuple


class ChmodPermissionsEngine:
    OCTAL_MAP = {
        0: "---", 1: "--x", 2: "-w-", 3: "-wx",
        4: "r--", 5: "r-x", 6: "rw-", 7: "rwx"
    }

    SYMBOLIC_MAP = {v: k for k, v in OCTAL_MAP.items()}

    @classmethod
    def octal_to_symbolic(cls, octal_code: str) -> Dict[str, str]:
        """
        Converts 3-digit or 4-digit octal string into POSIX symbolic representation.
        Example: '0755' -> '-rwxr-xr-x'
        """
        clean_oct = octal_code.zfill(4)
        if len(clean_oct) != 4 or not all(c in "01234567" for c in clean_oct):
            raise ValueError(f"Invalid octal permission string: '{octal_code}'")

        special = int(clean_oct[0])
        u = int(clean_oct[1])
        g = int(clean_oct[2])
        o = int(clean_oct[3])

        u_str = list(cls.OCTAL_MAP[u])
        g_str = list(cls.OCTAL_MAP[g])
        o_str = list(cls.OCTAL_MAP[o])

        # Apply Special Bits (SUID, SGID, Sticky)
        if special & 4:  # SUID
            u_str[2] = "s" if u_str[2] == "x" else "S"
        if special & 2:  # SGID
            g_str[2] = "s" if g_str[2] == "x" else "S"
        if special & 1:  # Sticky Bit
            o_str[2] = "t" if o_str[2] == "x" else "T"

        symbolic = "-" + "".join(u_str) + "".join(g_str) + "".join(o_str)

        # Security Risk Audit
        risk_level = "LOW"
        risk_warnings = []
        if clean_oct[-3:] == "777":
            risk_level = "CRITICAL"
            risk_warnings.append("World-writable and world-executable (chmod 777). Extreme security vulnerability.")
        elif o & 2:
            risk_level = "HIGH"
            risk_warnings.append("World-writable bit is enabled for untrusted external accounts.")
        elif special & 4 and u == 7:
            risk_level = "ELEVATED"
            risk_warnings.append("SUID bit set on executable owned by user.")

        return {
            "octal_input": octal_code,
            "normalized_octal": clean_oct,
            "symbolic_representation": symbolic,
            "user_class_permissions": "".join(u_str),
            "group_class_permissions": "".join(g_str),
            "others_class_permissions": "".join(o_str),
            "security_risk_level": risk_level,
            "security_audit_warnings": risk_warnings or ["Configuration satisfies standard security baselines."],
        }

    @classmethod
    def calculate_umask_effective(cls, base_octal: int, umask_octal: int) -> str:
        """
        Calculates effective permissions after applying umask bitwise mask:
        Effective = Base AND NOT Umask
        """
        effective = base_octal & (~umask_octal & 0o777)
        return oct(effective)[2:].zfill(3)


# Demonstration
if __name__ == "__main__":
    engine = ChmodPermissionsEngine()

    # 1. Standard Web Asset Permissions: 644
    p1 = engine.octal_to_symbolic("644")
    print("--- CHMOD 644 AUDIT ---")
    print(f"Octal:    {p1['normalized_octal']}")
    print(f"Symbolic: {p1['symbolic_representation']}")
    print(f"Risk:     {p1['security_risk_level']}")

    # 2. Critical Risk: 777
    p2 = engine.octal_to_symbolic("777")
    print("\n--- CHMOD 777 AUDIT ---")
    print(f"Octal:    {p2['normalized_octal']}")
    print(f"Symbolic: {p2['symbolic_representation']}")
    print(f"Risk:     {p2['security_risk_level']} -> {p2['security_audit_warnings'][0]}")

    # 3. Special Sticky Bit on /tmp: 1777
    p3 = engine.octal_to_symbolic("1777")
    print("\n--- CHMOD 1777 (STICKY BIT) AUDIT ---")
    print(f"Octal:    {p3['normalized_octal']}")
    print(f"Symbolic: {p3['symbolic_representation']}")

    # 4. Umask Calculation: Base File 666 with Umask 022 -> Effective 644
    eff = engine.calculate_umask_effective(0o666, 0o022)
    print(f"\nUmask Calculation: 0666 base with 0022 umask yields: 0{eff}")

TypeScript: Microservice Permissions Validator

export interface ChmodResult {
  octal: string;
  symbolic: string;
  isWorldWritable: boolean;
  isExecutable: boolean;
}

export class ChmodCalculatorService {
  private static readonly OCTAL_STRINGS = [
    "---", "--x", "-w-", "-wx", "r--", "r-x", "rw-", "rwx"
  ];

  public static parse(octalInput: string): ChmodResult {
    const padded = octalInput.padStart(3, "0");
    const u = parseInt(padded[0], 10);
    const g = parseInt(padded[1], 10);
    const o = parseInt(padded[2], 10);

    const symbolic = `-${this.OCTAL_STRINGS[u]}${this.OCTAL_STRINGS[g]}${this.OCTAL_STRINGS[o]}`;
    const isWorldWritable = (o & 2) !== 0;
    const isExecutable = (u & 1) !== 0 || (g & 1) !== 0 || (o & 1) !== 0;

    return {
      octal: padded,
      symbolic,
      isWorldWritable,
      isExecutable,
    };
  }
}

Standard Unix Permission Schemes Comparison Matrix

Permission CodeSymbolic StringTarget File / Directory AssetOperational PurposeSecurity Posture
chmod 644-rw-r--r--HTML files, CSS, images, JSON configsOwner can edit; web server & public can readSafe Industry Standard
chmod 755-rwxr-xr-xShell scripts, binary executables, directoriesOwner can execute & modify; others can executeSafe Industry Standard
chmod 600-rw-------SSH private keys (id_rsa), .env secretsOnly file owner has read & write accessHigh Security (Mandatory)
chmod 400-r--------AWS IAM PEM keys, read-only certificatesImmutable read-only for ownerMaximum Security
chmod 777-rwxrwxrwxTemporary staging debug testingUnrestricted access to any local or network userCritical Vulnerability
chmod 1777drwxrwxrwt/tmp, /var/tmp system directoriesWorld-writable, but only owner can delete filesStandard Shared Temp Dir

Catastrophic Security Traps & System Administrator Pitfalls

1. The "Lazy chmod 777" Anti-Pattern

When developers encounter a permission denied error in production (e.g., a web server cannot write an uploaded avatar to disk), a frequent mistake is executing:

sudo chmod -R 777 /var/www/html
  • Granting world-writable and world-executable permissions allows any local process, compromised web worker, or unprivileged container attacker to modify source files, overwrite system binaries, or upload reverse web shells.
  • Automated vulnerability scanners (e.g., AWS Security Hub, Nessus) instantly flag 777 files, causing compliance audit failures.
  • Remediation: Keep permissions at 644 for files and 755 for directories, adjusting group ownership instead (chown www-data:www-data).

2. The Directory Execute (+x) Traversal Bit Trap

Many new administrators assume directories only require read (+r) permissions to be browsed:

  • In POSIX filesystems, read (r) allows listing filenames, but execute (x) allows directory traversal and access to file contents / metadata (stat).
  • If a directory is set to chmod 644 (read-only without execute), users will see the filenames in ls, but every attempt to cd into the folder or open a file will fail with Permission denied. All accessible directories must maintain the execute bit (chmod 755).

3. SUID Binary Privilege Escalation

Setting the SUID bit on non-standard binaries (e.g., chmod 4755 /usr/bin/python or shell wrappers):

  • Allows unprivileged local users to spawn root shells by exploiting command-line execution flags or environment variables (LD_PRELOAD).
  • Regularly audit SUID binaries on production servers using:
    find / -perm -4000 -type f 2>/dev/null
    

Frequently Asked Questions

What is the difference between chmod 755 and 644?
Chmod 644 grants read and write to owner, and read-only to everyone else (standard for web files). Chmod 755 adds execute permissions (standard for directories and scripts).

Explore Related Utilities