Chmod Guide — File Permission Commands Explained

May 28, 2026

What Is chmod?

The chmod command changes file access permissions on Linux and Unix-like systems. Short for "change mode," it controls who can read, write, or execute a file. Every file and directory on your system has a permission mode, and chmod is the tool you use to modify it.

Without proper permissions, users cannot access files they need — or worse, can access files they should not. Understanding chmod is essential for system administration, deployment, and security.

Permission Basics

Every file has three categories of users who can access it:

  • Owner — the user who created the file
  • Group — users who share the file's group assignment
  • Others — everyone else on the system

Each category can have three types of access:

PermissionSymbolEffect on FilesEffect on Directories
ReadrView file contentsList directory contents
WritewModify file contentsAdd or remove files in directory
ExecutexRun the file as a programEnter the directory (cd into it)

These two concepts combine to form the permission string you see in ls -l output, like rwxr-xr-x.

Numeric (Octal) Mode

The numeric mode represents permissions as a three-digit octal number. Each digit corresponds to one user category: owner, group, and others.

The digit is the sum of these values:

PermissionValue
Read4
Write2
Execute1

Add the values for the permissions you want to grant. For example, read + write + execute = 4 + 2 + 1 = 7. Read + execute = 4 + 1 = 5.

Common Numeric Modes

ModePermissionsTypical Use
755rwxr-xr-xExecutable scripts, web directories
644rw-r--r--Regular files, documents
777rwxrwxrwxTemporary shared directories (avoid in production)
600rw-------SSH private keys, secret config files
700rwx------User-only directories
640rw-r-----Files shared within a group

Numeric Examples

# Set file to 755 (rwxr-xr-x)
chmod 755 script.sh

# Set file to 644 (rw-r--r--)
chmod 644 document.txt

# Set SSH key to 600 (rw-------)
chmod 600 ~/.ssh/id_rsa

# Apply to a directory and all contents recursively
chmod -R 755 /var/www/html

Symbolic Mode

Symbolic mode uses letters to specify who gets what permission. The format is who operator permission.

Who (User Classes)

LetterMeaning
uOwner (user)
gGroup
oOthers
aAll (same as ugo)

Operators

OperatorMeaning
+Add permission
-Remove permission
=Set exact permission (removes others)

Symbolic Examples

# Add execute permission for the owner
chmod u+x script.sh

# Remove write permission for group and others
chmod go-w document.txt

# Set exact permissions: owner read/write, group read, others nothing
chmod u=rw,g=r,o= document.txt

# Add read permission for everyone
chmod a+r readme.md

# Copy group permissions to others
chmod o=g file.txt

Symbolic mode is useful when you want to modify specific permissions without recalculating the full numeric value. It also makes your intent clearer in scripts.

Numeric vs Symbolic: When to Use Each

ScenarioRecommended ModeReason
Setting exact permissions from scratchNumericUnambiguous, concise
Modifying one permission bitSymbolicAvoids recalculating full mode
Writing deployment scriptsNumericReproducible, easy to document
Quick one-off adjustmentsSymbolicFaster mental model
Copying permissions from a referenceNumericDirect mapping to octal

Recursive Changes

Use the -R flag to apply permissions to a directory and everything inside it. Be careful — a blanket recursive change can break things.

# Safe: make directories executable but files read-only for group/others
find /var/www -type d -exec chmod 755 {} +
find /var/www -type f -exec chmod 644 {} +

# Dangerous: makes everything world-writable
chmod -R 777 /var/www  # Do not do this in production

The find approach is the recommended way to set different permissions for files versus directories.

Practical Tips

  • Always set the most restrictive permissions that allow your application to function
  • A file must be readable and executable to run as a script
  • A directory must be executable for users to enter it, even if they can read its listing
  • Scripts with a shebang line (like #!/bin/bash) need execute permission
  • Config files containing secrets should be mode 600, owned by the service account
  • Web server document roots typically use 755 for directories and 644 for files

Common Mistakes

  • Using 777 for convenience: This grants full access to everyone. It masks permission problems instead of solving them.
  • Forgetting execute on directories: Without x, users cannot cd into the directory, even with r permission.
  • Ignoring umask: Your umask determines default permissions for new files. Check it with umask before relying on defaults.
  • Recursive 777 on web roots: Attackers can overwrite any file. Use 755/644 instead.

Key Takeaways

  • chmod controls read, write, and execute access for owner, group, and others
  • Numeric mode uses octal values: read=4, write=2, execute=1
  • Symbolic mode uses u/g/o/a + +/-/= + r/w/x
  • Use 755 for executables, 644 for regular files, 600 for secrets
  • Always prefer the most restrictive permissions that work
  • Use find with -type d and -type f for safe recursive changes

Try It Yourself

Experiment with different permission combinations using our free chmod calculator. It converts between numeric and symbolic notation in real time, so you can see exactly what each mode does before running the command.