DevOps
Linux Chmod Permissions Calculator & Command Generator
Interactive visual permission matrix for Linux/Unix file systems. Calculate octal (755, 644), symbolic (-rwxr-xr-x), SUID/SGID/Sticky bits, and generate ready-to-run chmod commands.
Permission Matrix (Owner, Group, Public)
| Entity / Role | Read (r = 4) | Write (w = 2) | Execute (x = 1) |
|---|---|---|---|
| Owner (User / u) | |||
| Group (g) | |||
| Public / Others (o) |
Special Permission Flags (Advanced)
Generated Linux Shell Command
chmod 644 /var/www/html/index.htmlHow it works
Unix file permissions are encoded as a 12-bit binary integer split into four 3-bit octal octets. The first octet represents special flags: Setuid (4), Setgid (2), and Sticky (1). The remaining three octets represent Owner, Group, and Others, where Read = 4 (binary 100), Write = 2 (binary 010), and Execute = 1 (binary 001). Bitwise OR operations combine these flags to calculate numeric octals and symbolic rwx strings.
How to use it
- Select desired permissions (Read, Write, Execute) across Owner, Group, and Others using the interactive checkboxes.
- Alternatively, type an octal code (such as 755 or 644) or symbolic string (-rw-r--r--) into either input field to automatically update the matrix.
- Toggle special permission bits (SUID, SGID, Sticky bit) if configuring shared team directories or public scratch paths.
- Enter your target file or directory path to generate a tailored Linux shell command.
- Copy the generated command or octal representation to your clipboard.
Worked Examples
Example 1: Securing Private SSH Keys
Worked ExampleSetting required permissions on ~/.ssh/id_rsa so OpenSSH doesn't reject the key with 'permissions are too open'.
Input Payload
Owner: Read + Write; Group: None; Others: None
Output / Result
Octal: 0600 | Symbolic: -rw------- | Command: chmod 600 ~/.ssh/id_rsa
Why this happens: Ensures only the file owner can read the private key. OpenSSH strictly blocks keys with group or public read permissions.
Example 2: Standard Web Server Directory Permissions
Worked ExampleConfiguring Nginx / Apache document root directory on Ubuntu Linux.
Input Payload
Owner: rwx; Group: r-x; Others: r-x
Output / Result
Octal: 0755 | Symbolic: drwxr-xr-x | Command: chmod -R 755 /var/www/html
Why this happens: Allows the web server worker process (www-data) to traverse directories and serve static assets while restricting modifications to the root owner.
Example 3: Configuring Shared Group Collaboration Folder with SGID
Worked ExampleEnsuring all new files created inside /var/shared/ inherit the team group ownership automatically.
Input Payload
SGID bit enabled + 775 permissions
Output / Result
Octal: 2775 | Symbolic: drwxrwsr-x | Command: chmod 2775 /var/shared/
Why this happens: The Setgid bit (2) forces any file created within the directory to inherit the directory's group ID rather than the creator's primary group.
Edge Cases & Failure Modes
The Danger of Blanket chmod 777
Running 'chmod -R 777' on application or web directories grants full write access to every process and local user on the operating system.
Handling: Never use 777 in production. Use 755 for directories, 644 for files, and manage write permissions via Linux user groups (chown/chgrp).
Directory Execute vs Read Bit
On files, execute (x) allows binary execution. On directories, execute (x) is required to 'enter' (cd) and traverse the directory. A directory with read-only (r--) cannot be traversed.
Handling: Always grant execute (x) alongside read (r) on directories intended to be accessible to web servers or users.
SUID on Shell Scripts
Modern Linux kernels deliberately ignore the SUID bit on interpreted scripts (#/bin/bash, #/usr/bin/python) for security reasons to prevent privilege escalation race conditions.
Handling: Only compiled C/Rust binaries can utilize SUID; for scripts requiring elevated privileges, use sudoers with specific command grants.
Privacy & Local Execution Guarantee
All permission calculations, bitwise math, symbolic translations, and command string formatting occur 100% client-side in your local browser JavaScript engine. No file paths or permission configurations leave your device.
Frequently Asked Questions
What does the first digit in a 4-digit chmod code mean (e.g. 0755 vs 2775)?
The first digit specifies special permission flags: 4 for Setuid (SUID), 2 for Setgid (SGID), and 1 for the Sticky bit. When no special flags are set, the first digit is 0 (0755).
Why should web server files be 644 and directories 755?
Files only need Read (4) and Write (2) for the owner, and Read (4) for the web server to serve them (644). Directories require the Execute (1) bit for the operating system to traverse into subfolders and read directory contents (755).
What is the Sticky Bit and why is it used on /tmp?
The sticky bit (1777, symbolized by 't') allows all users to write files into a shared directory, but prevents users from deleting or renaming files owned by someone else. It is universally used on /tmp and /var/tmp.
How do I apply permissions to only files or only directories recursively?
In Linux terminal, run 'find /path -type f -exec chmod 644 {} +' for files, and 'find /path -type d -exec chmod 755 {} +' for directories.
Related articles
Related tools
Related services
Database Performance & Hardened DevOps Consulting
Struggling with slow queries, unindexed joins, container orchestration, or legacy schema migrations across PostgreSQL, MySQL, or Oracle?
- Query profiling & sub-millisecond index tuning
- Zero-downtime database migration pipelines
- Hardened Kubernetes & container topologies
Next step
Need production-grade systems, resilient APIs, or cloud infrastructure?
Our senior software architects design, build, and optimize mission-critical software systems on deterministic timelines.
