DTTooleras

chmod Command Explained: Unix File Permissions Made Simple

A clear, practical guide to Unix file permissions and the chmod command. Understand numeric and symbolic notation, common permission patterns, and security best practices.

DevToolsHub Team15 min read642 words

What Are File Permissions?

Every file and directory in Unix/Linux has three sets of permissions that control who can read, write, and execute it:

  • Owner (u) — The user who owns the file
  • Group (g) — Users in the file's group
  • Others (o) — Everyone else

Each set has three permission types:

PermissionSymbolNumericMeaning for FilesMeaning for Directories
Readr4View file contentsList directory contents
Writew2Modify fileCreate/delete files in directory
Executex1Run as programEnter (cd into) directory

Reading Permission Strings

When you run ls -la, you see permissions like:

-rwxr-xr-x  1 alice  staff  4096 Jan 15 10:30 script.sh
drwxr-xr-x  5 alice  staff   160 Jan 15 10:30 src/

Breaking down -rwxr-xr-x:

-    rwx    r-x    r-x
│    │      │      │
│    │      │      └── Others: read + execute
│    │      └── Group: read + execute
│    └── Owner: read + write + execute
└── File type (- = file, d = directory, l = symlink)

Numeric (Octal) Notation

Each permission has a numeric value. Add them up for each set:

r = 4
w = 2
x = 1

rwx = 4 + 2 + 1 = 7
r-x = 4 + 0 + 1 = 5
r-- = 4 + 0 + 0 = 4
--- = 0 + 0 + 0 = 0

So rwxr-xr-x = 755

Common Permission Numbers

NumberPermissionsUse Case
755rwxr-xr-xExecutable scripts, directories
644rw-r--r--Regular files (HTML, CSS, images)
600rw-------Private files (SSH keys, .env)
700rwx------Private directories, scripts
777rwxrwxrwxFull access (avoid in production!)
444r--r--r--Read-only files
750rwxr-x---Group-accessible executables
640rw-r-----Group-readable files

The chmod Command

Numeric Mode

chmod 755 script.sh
chmod 644 index.html
chmod 600 .env
chmod -R 755 public/    # Recursive

Symbolic Mode

chmod u+x script.sh      # Add execute for owner
chmod g+w file.txt        # Add write for group
chmod o-r secret.txt      # Remove read for others
chmod a+r public.html     # Add read for all
chmod u=rwx,g=rx,o=rx script.sh  # Set exact permissions

Symbolic Operators

OperatorMeaning
+Add permission
-Remove permission
=Set exact permission

Symbolic Targets

TargetMeaning
uOwner (user)
gGroup
oOthers
aAll (owner + group + others)

Security Best Practices

  1. Never use 777 — It gives everyone full access. If something "only works with 777", the real problem is elsewhere.

  2. SSH keys must be 600 — SSH refuses to use keys with loose permissions:

chmod 600 ~/.ssh/id_rsa
chmod 644 ~/.ssh/id_rsa.pub
chmod 700 ~/.ssh/
  1. Web server files: 644, directories: 755 — The web server user needs read access, not write.

  2. Environment files: 600.env files contain secrets and should only be readable by the owner.

  3. Use groups for shared access — Instead of making files world-readable, add users to a group.

Calculate permissions visually with our Chmod Calculator — toggle permissions and get the numeric and symbolic notation instantly.

Related Tools & Articles

chmodfile permissionsunix permissionschmod calculatorlinux permissionschmod 755chmod 644

Related articles

All articles

Practice with free tools

200+ free developer tools that run in your browser.

Browse all tools →