Chmod Linux Permissions Calculator
Calculate Linux file permissions visually. Convert between octal numbers (755, 644) and symbolic notation (-rwxr-xr-x) with zero server tracking.
Understanding Linux File Permissions and the Chmod Command
Quick Answer: In Linux and Unix filesystems, chmod (short for "change mode") controls file system permissions across three distinct user classes: Owner (User), Group, and Others (World). Permissions are defined by three foundational operations: Read (4), Write (2), and Execute (1). Summing these bit values generates three-digit octal codes like 755 (rwxr-xr-x) for directories and scripts, or 644 (rw-r--r--) for standard documents, establishing fine-grained security boundaries across the operating system.
Every file, directory, socket, and pipe created in POSIX-compliant operating systems like Linux, macOS, FreeBSD, and OpenBSD stores metadata within its inode. This metadata defines who owns the resource, which group shares administrative access, and what specific actions any system process can perform. The chmod utility is the primary administrative command used to inspect and adjust these discretionary access control flags.
The Anatomy of POSIX Permissions: User Classes
Unix security categorizes processes and system accounts into three distinct tiers of authority when evaluating access requests:
- Owner (User,
u): The specific user account that owns the file. Typically, this is the user who created the file, though ownership can be reassigned using thechowncommand. The owner generally holds the highest level of authority over the asset. - Group (
g): A collection of system users grouped together under a shared identifier (GID). Assigning permissions to a group enables team members, background services, or web server daemons to collaborate on shared files without granting universal access. - Others (World,
o): Every other user account on the operating system that is neither the file owner nor a member of the assigned group. This represents the public scope of the server. - All (
a): A shorthand notation in symbolic commands that targets all three tiers (Owner, Group, and Others) simultaneously.
The Mathematical Foundation: Octal and Binary Weights
Behind every human-readable permission string lies a 9-bit binary bitmask stored in the filesystem inode. Each of the three user classes is governed by a 3-bit triplet representing Read, Write, and Execute rights. Because 3 binary bits can represent values from 0 (000) to 7 (111), Linux maps these triplets cleanly to the base-8 octal numbering system:
- Read (
r): Binary100= Value4. For regular files, read permission permits opening and viewing file contents. For directories, read permission allows listing directory entries (e.g., executingls). - Write (
w): Binary010= Value2. For files, write permission allows modifying, truncating, appending, or overwriting file data. For directories, write permission allows creating, renaming, moving, or deleting files within that directory. - Execute (
x): Binary001= Value1. For files, execute permission allows running compiled binary programs or shell scripts. For directories, execute permission allows entering or traversing the directory (e.g., executingcd) and accessing child metadata.
The Complete Octal Combinations Table
| Octal Digit | Binary Bitmask | Symbolic String | Effective Access Capability |
|---|---|---|---|
0 |
000 |
--- |
No permissions granted. Complete access denial. |
1 |
001 |
--x |
Execute only. Can execute program or traverse folder, but cannot read or modify. |
2 |
010 |
-w- |
Write only. Blind write capability without read access (rarely used). |
3 |
011 |
-wx |
Write and execute. Can write files and traverse, but cannot read or list contents. |
4 |
100 |
r-- |
Read only. Can view file contents or list directory files; no modifications allowed. |
5 |
101 |
r-x |
Read and execute. Standard directory traversal and binary execution mode. |
6 |
110 |
rw- |
Read and write. Standard document and editable data file mode without execution. |
7 |
111 |
rwx |
Full access. Unrestricted capability to read, write, modify, and execute. |
File Types in Symbolic Directory Listings
When executing ls -l in a terminal, the output string begins with a 10-character sequence (such as -rwxr-xr-x or drwxr-xr-x). The first character identifies the file system object type rather than an access privilege:
-: Regular file (e.g., text document, compressed archive, compiled binary).d: Directory (folder containing directory entries).l: Symbolic link (soft link pointing to another path).c: Character device file (unbuffered hardware stream like terminal/dev/tty).b: Block device file (buffered storage hardware like disk partition/dev/sda1).s: Local Unix domain socket (inter-process communication endpoint).p: Named pipe (FIFO channel for process redirection).
Special Permission Bits: SUID, SGID, and the Sticky Bit
Beyond standard read, write, and execute bits, Linux provides three advanced permission flags controlled by an optional fourth leading octal digit:
- SUID (Set User ID, Octal
4000): When applied to an executable binary, any user running the program temporarily executes it with the permissions of the file owner rather than their own. A classic example is thepasswdbinary (mode 4755), which allows regular users to update their password inside root-owned shadow files. In symbolic strings, an executable file shows ansin the owner execute position (e.g.,-rwsr-xr-x). - SGID (Set Group ID, Octal
2000): For binaries, the program executes with the effective group privileges of the file. For directories, SGID enforces inheritance: any newly created file inside that directory automatically inherits the directory's group ownership rather than the primary group of the creating user. This is indispensable for shared engineering team directories. In symbolic strings, it appears as ansin the group execute position. - Sticky Bit (Octal
1000): Applied almost exclusively to shared directories like/tmp(mode 1777). In a sticky directory, while any user may create files, only the root user or the specific user who created a file is permitted to delete or rename it. In symbolic strings, it appears as atin the others execute position (e.g.,drwxrwxrwt).
Understanding Umask and Default File Modes
When a program or user creates a new file, the operating system does not assign arbitrary permissions. Instead, the process specifies a base mode, which the kernel filters through the current process umask (user creation mask):
- Default base mode for directories is full access:
0777. - Default base mode for regular files excludes execution:
0666. - The effective permission is calculated via bitwise logical AND with the inverted umask:
Mode = Base & (~umask). In standard non-overlapping octal masks, this is simplyBase - umask. - Standard server umask is
0022. This converts directory base 777 to755(drwxr-xr-x) and file base 666 to644(-rw-r--r--). - High-security environments frequently configure umask to
0027(yielding directory mode 750 and file mode 640) or0077(private mode 700 and 600).
Production Hardening: Safe Permission Recipes
Applying proper permissions is critical to safeguarding Linux servers against privilege escalation and data theft:
- Web Server Content (Nginx, Apache): Directories should be set to
755(drwxr-xr-x), and static files (HTML, CSS, JS, images) should be set to644(-rw-r--r--). This allows the web server daemon (such aswww-dataornginx) to read and serve content while preventing remote tampering. - Sensitive Secrets and Environment Files: Application configuration files containing API keys, database credentials, or private secrets (e.g.,
.env,wp-config.php) must be locked down to600(-rw-------) or400(-r--------) owned by the application runtime user. - SSH Keys: Private key files located in
~/.ssh/id_rsaor~/.ssh/id_ed25519require strict permissions of600. If permissions allow group or other access, OpenSSH client daemons will abort the connection with a "Permissions are too open" warning. The~/.ssh/directory itself must be set to700. - Administrative Shell Scripts: Automation scripts intended for system execution should be set to
750(-rwxr-x---) or755(-rwxr-xr-x), ensuring the execute bit is set for required operators.
The Hazards of Chmod 777 and Anti-Patterns
One of the most dangerous and common mistakes in server administration is running chmod 777 -R to resolve a "Permission Denied" error. Setting mode 777 grants read, write, and execute authority to every account on the system. If your web application contains an arbitrary file upload vulnerability, any remote attacker can upload a web shell and execute arbitrary commands with ease. In addition, any malicious local process or unprivileged daemon can overwrite system scripts, corrupt databases, or delete critical directories.
Safe Bulk Permission Updates: The Find Pattern
A common operational challenge occurs when deploying web applications or extracting archives where file and directory permissions have become inconsistent. Running chmod -R 755 /path/to/site is problematic because it assigns the execute bit to every text file, stylesheet, and image, violating security best practices.
The standard, production-grade solution uses the POSIX find command with parallel execution markers to separate directories from regular files:
# Correctly set directories to 755 without affecting files
find /var/www/my-app -type d -exec chmod 755 {} +
# Correctly set regular files to 644 without stripping directory traversal
find /var/www/my-app -type f -exec chmod 644 {} +
# Lock down sensitive environment secrets
chmod 600 /var/www/my-app/.env
Symbolic vs Octal Modes in Daily Workflows
The chmod command accepts two distinct input styles:
- Octal Mode (e.g.,
chmod 755 file): Replaces all 9 permission bits simultaneously with an absolute configuration. This is clean, deterministic, and ideal for automation scripts. - Symbolic Mode (e.g.,
chmod u+x,g-w,o=r file): Adjusts specific flags relative to existing permissions. The operator+adds a permission,-removes a permission, and=explicitly sets the exact permission for that specific user class while leaving other classes untouched.
Troubleshooting Permission Denied Errors
When debugging access issues in Linux environments, consider the complete authentication chain:
- Directory Traversal: To access any file, every parent directory leading down from the root filesystem (
/) must have the execute (x) bit enabled for the calling user. If a parent folder lacks execute rights, access to child files is blocked even if the target file has mode 777. - File Ownership Mismatches: Permission bits apply strictly according to the owner and group assigned to the file. Always inspect ownership using
ls -lorstat filename. If ownership is incorrect, usechown user:group filenamebefore adjusting permissions. - Immutable Filesystem Attributes: If a file cannot be modified even by the root user with mode 777, check for filesystem immutability flags using
lsattr filename. Clear the immutable bit usingchattr -i filename.
Frequently Asked Questions
What does chmod 755 mean in Linux permissions?
Chmod 755 sets permissions so the file owner has read, write, and execute permissions (7), while the group and all other users have read and execute permissions (5). In symbolic notation, this is represented as rwxr-xr-x.
How are numeric chmod values calculated?
Chmod values are calculated by summing the numeric weights of assigned permissions: Read equals 4, Write equals 2, and Execute equals 1. For example, read plus execute gives 5 (4+1), and full access gives 7 (4+2+1).
What do the three digits in chmod 755 or 644 represent?
The three digits represent distinct user classes in order: the first digit applies to the file Owner (u), the second to the Group (g), and the third to Others (o). Each digit is the independent sum of read, write, and execute permissions for that class.
What is the recommended permission for web server files and directories?
Standard security guidelines recommend 755 (drwxr-xr-x) for web directories so web servers can traverse and list them, and 644 (-rw-r--r--) for web assets like HTML, CSS, and images to allow reading while preventing unauthorized execution or modification.
Why is using chmod 777 dangerous in production environments?
Chmod 777 grants read, write, and execute permissions to all users on the operating system. Any compromised local process, rogue daemon, or unauthorized user can modify, overwrite, execute, or delete those files, creating severe security vulnerabilities.
What permission should be assigned to private SSH keys?
OpenSSH strictly requires private key files like id_rsa to have permissions restricted to chmod 600 (-rw-------) or chmod 400 (-r--------). If permissions are too open, SSH clients will refuse to authenticate and reject the key connection.
What are special permissions like SUID, SGID, and the Sticky Bit?
Special permissions use a fourth leading octal digit: SUID (4) executes a binary with the permissions of the file owner, SGID (2) executes with the group privileges or enforces directory group inheritance, and the Sticky Bit (1) prevents non-owners from deleting files in shared directories like /tmp.
What is umask and how does it determine default file permissions?
The umask (user file-creation mode mask) is an octal filter subtracted from base system permissions when creating new files (base 666) or directories (base 777). A standard umask of 022 results in default file permissions of 644 and directory permissions of 755.
How do you change permissions recursively on directories versus files?
To avoid breaking web servers by setting execution bits on plain files, use find commands instead of chmod -R. Run find . -type d -exec chmod 755 {} + for directories and find . -type f -exec chmod 644 {} + for files.
Does this chmod calculator transmit my file names or server data?
No. All calculation logic runs entirely within your browser using client-side JavaScript. No file paths, usernames, server commands, or session data are ever sent across the network.