Linux File Permissions Explained: Octal & Symbolic Guide
Learn linux file permissions with syntax, essential flags, practical terminal examples, real-world sysadmin workflows, security tips, and troubleshooting.
11 min read
Learn linux file permissions with syntax, essential flags, practical terminal examples, real-world sysadmin workflows, security tips, and troubleshooting.
- What chmod Does and When to Use It
- Availability and Installation Across Linux Distributions
- Command Syntax, Arguments, and Exit Status Codes
A deep understanding of linux file permissions is the foundation of multi-user operating system security, server hardening, and application isolation. Every file, directory, named pipe, socket, and device node created on a Linux filesystem contains discretionary access control (DAC) metadata stored within its inode table entry.
Linux file permissions control access to files and directories across three distinct classes: User (owner), Group, and Others. Each class is assigned Read (4), Write (2), and Execute (1) rights, represented as a 3-digit octal mode (such as 755 or 644) or a 10-character symbolic string (such as -rwxr-xr-x) in directory listings.
When a process attempts to read, modify, or execute an object, the Linux kernel evaluates the process's effective user ID (EUID) and effective group IDs (EGID) against the target inode's mode bits. Access is checked in a strict precedence order: if the process matches the file owner, user permission bits apply; if not, but the process belongs to the file's group, group bits apply; otherwise, other (world) permission bits govern access.
This technical guide explains how read, write, and execute bits function across both regular files and directories, breaks down octal numeric versus symbolic representations, demonstrates how the process umask calculates default permissions, and walks through auditing tools like stat and ls -l.
What chmod Does and When to Use It
In the Linux Virtual File System (VFS), an inode stores permissions inside a 16-bit integer field named st_mode. The highest 4 bits define the file type (regular file, directory, symbolic link, character device, block device, FIFO pipe, or UNIX domain socket). The remaining 12 bits encode access permissions: 3 special attribute bits (SUID 04000, SGID 02000, and Sticky Bit 01000), followed by 9 standard permission bits divided into three sets of 3 bits each for User (owner), Group, and Other.
The interpretation of permission bits differs significantly between regular files and directories. For a regular file, Read (r) permits viewing data bytes, Write (w) permits altering or truncating bytes, and Execute (x) allows the kernel's execve(2) system call to load the file into memory as a binary program or interpreter script. For a directory, Read (r) allows listing directory entries (filenames) via readdir(3), Write (w) allows creating, renaming, or unlinking entries within the directory (provided execute is also present), and Execute (x), also called the search bit, allows traversing into the directory and accessing inodes referenced by its entries.
Linux enforces discretionary access control (DAC) by evaluating the effective User ID (EUID), effective Group ID (EGID), and supplementary groups against inode permission bits. When chmod executes, the Virtual File System (VFS) and active Linux Security Modules (SELinux or AppArmor) validate the caller's privileges before committing changes to disk or account databases.
Availability and Installation Across Linux Distributions
The chmod utility is packaged in coreutils across mainstream Linux distributions. It is pre-installed on standard Ubuntu, Debian, RHEL, Rocky Linux, AlmaLinux, Fedora, and Arch Linux systems, while minimal container images may require manual installation:
Before running administrative tasks or automation scripts, verify whether chmod is installed and inspect which binary path and version your shell resolves:
type -a chmod
chmod --version 2>/dev/null || man -f chmod
# Illustrative output (reviewed against documentation)
chmod is /usr/bin/chmod
chmod (coreutils)
# Debian / Ubuntu
sudo apt-get update && sudo apt-get install -y coreutils
# RHEL / Rocky / AlmaLinux / Fedora
sudo dnf install -y coreutils
# Arch Linux
sudo pacman -S --noconfirm coreutils
# Alpine Linux
sudo apk add --no-cache coreutils
Command Syntax, Arguments, and Exit Status Codes
chmod [OPTION]... MODE[,MODE]... FILE... | stat -c "%a %A %n" FILE...
File permissions are primarily inspected using ls -l or stat [OPTION]... FILE... and modified using chmod [OPTION]... MODE FILE.... The 10-character string rendered by ls -l (e.g., -rwxr-xr--) begins with a file type indicator (- for regular file, d for directory, l for symlink), followed by three triplets representing User (rwx), Group (r-x), and Other (r--).
Octal notation assigns a weighted numeric value to each permission bit: Read = 4, Write = 2, and Execute = 1. Summing the weights yields a single octal digit (0 through 7) for each class: 7 (4+2+1 = rwx), 6 (4+2 = rw-), 5 (4+1 = r-x), and 4 (4 = r--). A mode of 755 signifies User=rwx (7), Group=r-x (5), and Other=r-x (5).
0— Successful permission query or modification.1— Minor operational failure, such as attempting to modify a file without sufficient ownership or permissions.2— Syntax error or invalid mode argument provided to chmod or stat.
Important Options and Flags Reference
| Option / Flag | Long Form / Argument | Technical Behavior and Purpose |
|---|---|---|
-c | --changes | Like verbose, but reports only when a change is actually made to a file mode. |
-v | --verbose | Outputs a diagnostic message for every file processed by chmod. |
-R | --recursive | Recursively applies mode changes across files and subdirectories. |
--reference | --reference=RFILE | Copies the permission mode of reference file RFILE instead of specifying an explicit mode. |
u, g, o, a | User, Group, Other, All | Symbolic classes: user (owner), group, others, and all (user + group + others). |
+, -, = | Add, Remove, Assign | Symbolic operators: add permission, remove permission, and assign exact permission. |
r, w, x | Read, Write, Execute | Standard permission bits: read (4), write (2), and execute (1). |
X | Conditional Execute | Conditional execute: grants execute only if the target is a directory or already has execute set for some user. |
When managing permissions, deciding between numeric octal mode (e.g., chmod 644 file.txt) and symbolic notation (e.g., chmod u+x file.sh) depends on operational context. Octal mode sets an absolute permission state, completely overwriting existing bits regardless of prior configuration. This is ideal for provisioning and infrastructure as code.
In contrast, symbolic modifiers (like chmod g+w,o-rwx file.txt) perform incremental bitwise mutations without altering unrelated bits. Symbolic notation is safer during interactive administrative tasks where you need to add execute rights to an executable script (chmod +x script.sh) without having to calculate or disturb the existing read and write permissions of the file.
When combining short flags on the command line, POSIX and GNU utilities allow clustering boolean flags behind a single hyphen, provided any option taking an argument appears last. In automated shell scripts, using long-form GNU options where portable makes self-documenting code that is easier to audit during peer review.
Practical Basic and Advanced Usage Examples
1. Inspect File Permissions in Long Listing Format
Use ls -l to display file type, symbolic permissions, link count, owner, group, file size, and timestamp.
touch test_file.txt && chmod 640 test_file.txt
ls -l test_file.txt
# Illustrative output (reviewed against documentation)
-rw-r----- 1 admin webapps 0 Oct 22 20:25 test_file.txt
The first character '-' indicates a regular file. 'rw-' grants read/write to user admin, 'r--' grants read-only to group webapps, and '---' denies all access to others.
2. Display Octal and Human-Readable Permissions with stat
Use the stat command to extract exact numeric octal permissions alongside symbolic representation.
stat -c "File: %n | Octal: %a | Symbolic: %A | Owner: %U:%G" test_file.txt
# Illustrative output (reviewed against documentation)
File: test_file.txt | Octal: 640 | Symbolic: -rw-r----- | Owner: admin:webapps
The format flags %a and %A extract the exact 3-digit octal and 10-character symbolic modes cleanly for scripts.
3. Set Standard Permissions for a Regular File (644)
Apply the standard security baseline for configuration and document files: read/write for owner, read-only for all others.
chmod 644 config.json
ls -l config.json
# Illustrative output (reviewed against documentation)
-rw-r--r-- 1 admin admin 512 Oct 22 20:26 config.json
Mode 644 represents User=4+2 (rw), Group=4 (r), and Other=4 (r), preventing unauthorized users from modifying configuration files.
4. Set Standard Permissions for an Executable Script (755)
Grant execute privileges to a shell script while protecting it from modification by non-owners.
chmod 755 deploy.sh
ls -l deploy.sh
# Illustrative output (reviewed against documentation)
-rwxr-xr-x 1 admin admin 1024 Oct 22 20:27 deploy.sh
Mode 755 assigns read, write, and execute (7) to the owner, and read and execute (5) to group members and other users.
5. Modify Permissions Incrementally Using Symbolic Notation
Add group write permissions while stripping all permissions from others without altering owner bits.
chmod g+w,o-rwx shared_doc.txt
ls -l shared_doc.txt
# Illustrative output (reviewed against documentation)
-rw-rw---- 1 admin team 2048 Oct 22 20:28 shared_doc.txt
Symbolic operators add write to group (g+w) and remove read, write, and execute from other (o-rwx) cleanly.
6. Inspect Default umask Calculation for Newly Created Files
View the active umask value and demonstrate how the kernel computes default permissions for new files and directories.
umask
# Demonstrating creation:
touch new_file.txt && mkdir new_dir
stat -c "%a %A %n" new_file.txt new_dir
# Illustrative output (reviewed against documentation)
0022
644 -rw-r--r-- new_file.txt
755 drwxr-xr-x new_dir
The umask 0022 subtracts write from group and others, converting base file mode 666 to 644, and base directory mode 777 to 755.
Real-World Workflows, Pipelines, and Shell Automation
System-Wide Permission Hardening Audit for Sensitive Files
Audit sensitive system configuration files (/etc/shadow, /etc/passwd, SSH keys) to ensure permissions comply with CIS security benchmarks and do not expose credentials.
# Audit critical configuration files for overly permissive bits
FILES=("/etc/passwd" "/etc/shadow" "/etc/ssh/sshd_config")
echo "Auditing security permissions..."
for f in "${FILES[@]}"; do
if [ -e "$f" ]; then
stat -c "Permission: %a | Mode: %A | Owner: %U:%G | File: %n" "$f"
fi
done
# Illustrative output (reviewed against documentation)
Auditing security permissions...
Permission: 644 | Mode: -rw-r--r-- | Owner: root:root | File: /etc/passwd
Permission: 640 | Mode: -rw-r----- | Owner: root:shadow | File: /etc/shadow
Permission: 600 | Mode: -rw------- | Owner: root:root | File: /etc/ssh/sshd_config
Confirms that /etc/shadow is restricted to root:shadow and sshd_config is readable only by root (600), preventing unauthorized credential leaks.
Shared Collaborative Group Directory Provisioning
Configure a shared collaborative folder where team members can create and modify files while inheriting group ownership automatically.
sudo mkdir -p /srv/teamdata
sudo chown -R root:developers /srv/teamdata
# Grant read/write/execute and set SGID (2775)
sudo chmod 2775 /srv/teamdata
# Verify SGID bit
ls -ld /srv/teamdata
# Illustrative output (reviewed against documentation)
drwxrwsr-x 2 root developers 4096 Oct 22 20:30 /srv/teamdata
The 's' in the group execute position represents the Set Group ID (SGID) bit (2775), ensuring that any new files created inside inherit group 'developers'.
Pipelines, Redirection, Quoting, and Shell Expansion
When embedding chmod inside shell pipelines (|), conditional chains (&& and ||), or command substitutions ($(...)), the calling shell performs tilde expansion, variable interpolation, and globbing before invoking the binary. Always wrap paths, patterns, and variables in quotes so whitespace and wildcard characters (*, ?) are not expanded prematurely, and use set -euo pipefail in unattended scripts.
Permissions, Security Implications, and Safe Execution
Carelessly changing permissions on root-owned system directories (such as chmod 777 / or chmod -R 700 /etc) can break system authentication (PAM), disable SSH logins, and prevent daemon startup. Never modify permissions on system paths without explicit requirements.
In Linux DAC security, permission checks terminate on the first match. If you own a file with permissions 000 (no permissions) and belong to a group with 777 permissions, you will be denied access because your identity matches the owner class first, where all access is explicitly disabled.
Beyond standard DAC bits, modern Linux systems deploy POSIX Access Control Lists (ACLs, via getfacl/setfacl) for fine-grained multi-user authorization, as well as Mandatory Access Control (MAC) systems like SELinux and AppArmor that enforce security policies regardless of file permission bits.
GNU/Linux, BSD, and BusyBox Implementation Differences
Standard DAC permissions (rwx for User, Group, Other) and umask handling are standardized under POSIX.1-2017 and operate identically across Linux, FreeBSD, OpenBSD, and macOS.
However, extended permissions, default ACL inheritance, and security context attributes (like SELinux contexts displayed by ls -Z) are Linux-specific. Filesystems like FAT32 and exFAT do not support POSIX permission bits natively; when mounted in Linux, permissions are simulated globally via mount options (umask, dmask, fmask).
Troubleshooting Common Errors and Diagnostics
Cannot access file despite having read permissions (-rw-r--r--)
Root Cause: The user lacks execute (x) search permissions on one or more parent directories along the path leading to the target file.
Resolution: Check the permissions of every ancestor directory leading to the file. Ensure that each directory has at least execute (x) permissions for the user or group.
namei -l /var/www/html/app/config.json
Script fails with 'bash: ./script.sh: Permission denied'
Root Cause: The script file lacks execute (x) mode bits, or the filesystem is mounted with the 'noexec' mount option.
Resolution: Add execute permission to the file using chmod +x script.sh, or verify mount options using findmnt if execute is already enabled.
chmod +x script.sh
./script.sh
chmod: changing permissions of 'file': Operation not permitted
Root Cause: Only the owner of a file or the root superuser has the authority to modify its permission mode bits.
Resolution: Check file ownership using ls -l. If you are not the file owner, run the command with sudo or ask the file owner to execute the change.
ls -l file.txt
sudo chmod 644 file.txt
Alternatives, Related Commands, and Related Tutorials
- Chmod Recursive in Linux: Change Permissions on Folders — Practical syntax, flags, and examples for
chmod. - What Does chmod 777 Mean and Why You Should Avoid It — Practical syntax, flags, and examples for
chmod. - chmod Command in Linux: Syntax, Flags & Practical Guide — Practical syntax, flags, and examples for
chmod. - ls Command in Linux: List Files, Flags & Practical Guide — Practical syntax, flags, and examples for
ls. - 25 Best Linux Commands Every Sysadmin Should Know — Core command-line utilities for daily Linux server administration.
- How to Find a File in Linux from the Command Line — Practical file search patterns across Linux directories.
- Linux Commands Knowledge Hub (#linux-commands) — Browse all Linux command-line tutorials and system administration references.
Authoritative References and Official Documentation

UNIX and Linux System Administration Handbook, 5th Edition
Frequently Asked Questions
Quick answers to common questions and configurations
/tmp) prevents users from deleting files owned by others.Editorial Disclosure: Website Vidya is supported by our readers. When you purchase hosting, tools, or software through our verified partner links, we may earn an affiliate commission at no extra cost to you. We only recommend solutions we trust and rigorously verify.
Rajesh Ray
I’m Rajesh Rai, a full-stack developer, Linux administrator, and technology enthusiast passionate about making complex technology easier to understand and use.
Most Read Guides
TrendingUbuntu Server Not Booting? 10 Simple Steps to Fix It Fast
How to Create a 3D Button in HTML and CSS: Easy Steps
How to Install Python and Pip on Ubuntu 24.04 LTS
How to Install Nginx on Ubuntu 24.04
How to Install Python on Ubuntu 24.04 LTS
Related Technical Guides
Tested runbooks, server administration walkthroughs, and troubleshooting guides

Join the Conversation & Perspective
Have thoughts, counterpoints, or reflections on this story? Engage directly with fellow readers and editorial contributors.
No comments on this guide yet. Be the first to share your thoughts or ask a question!