ToolsOps

Linux chmod permissions guide

Linux chmod permissions: when to use 755 vs 777, what 644 means, rwx permissions, octal and symbolic notation, and safe examples for files and scripts.

What chmod is

chmod is the standard Unix/Linux command for changing the permissions of a file or directory. It controls who can read it (r), modify it (w) or run it (x), applying those permissions across three audiences: the owner, the associated group, and everyone else.

Owner, group and others

Every Linux file has three permission blocks, one per audience:

  • Owner (user): the user who created the file, unless changed with chown.
  • Group: users belonging to the file's associated group. Useful for team-shared files.
  • Others: any other user on the system.

The r, w, x bits

Each audience has three bits: read, write and execute. In octal each bit adds:

  • 4 = r (read)
  • 2 = w (write)
  • 1 = x (execute)

Adding them gives the value per audience:

OctalSymbolicMeaning
7rwxRead, write and execute
6rw-Read and write
5r-xRead and execute
4r--Read only
0---No permissions

Safe examples

The following values cover the most common cases without dropping into the wide-open chmod 777 territory:

  • chmod 755 script.sh - public executable script; only the owner can edit.
  • chmod 644 file.txt - config file readable by everyone, writable only by the owner.
  • chmod 700 private-script.sh - only the owner reads, writes and runs. Group and others have no access.
  • chmod 600 secret.txt - only the owner reads and writes. Typical for SSH private keys.
  • chmod 777 - grants rwx to everyone. Avoid it: any process or user can modify and run the file. A more restrictive value (755 or 750) is usually enough.

755 vs 777: when to pick which

A common question when adjusting Linux permissions is whether to use 755 or 777. The difference is what they grant to group and others on the system:

  • chmod 755 (rwxr-xr-x): the owner reads, writes and executes; group and others only read and execute. It's the typical value for public directories and executable scripts.
  • chmod 777 (rwxrwxrwx): rwx for everyone. Any user or process on the system can modify the file. It almost always hides an ownership or group issue.

If a script "only works" with 777, it's usually an ownership problem: try chown to the right user first, or adjust the shared group. The execute bit (x) on files is granted with 755; on directories, x means "can enter and traverse", also with 755.

Octal vs symbolic

Octal notation sets absolute permissions. Symbolic notation modifies them incrementally:

  • chmod u+x script.sh - adds execute to the owner without touching the rest.
  • chmod go-w file.txt - removes write from group and others, leaves the owner untouched.
  • chmod a+r public.html - adds read for all audiences.

Audiences are u (user/owner), g (group), o (others) and a (all). Operators are + (add), - (remove) and = (set exactly).

Special bits (setuid, setgid, sticky)

Linux supports three extra bits that prepend the standard octal mode:

  • setuid (4xxx): the executable runs as the file owner, not the user who invoked it. Example: /usr/bin/passwd.
  • setgid (2xxx): on executables, runs with the file's group. On directories, new files inherit the directory's group.
  • sticky (1xxx): on directories, only the file owner can delete their files, even if others have w. Typical on /tmp.

Common mistakes

  • Using chmod 777 "to make it work". It usually hides an owner, group or path issue.
  • Forgetting that accessing a file also requires read/execute permission on the directory.
  • Running chmod -R 777 . on a project and leaving the system vulnerable.
  • Not checking the owner with ls -l before changing permissions.
  • Assuming a copied file keeps its permissions: cp -p preserves them, plain cp does not.

Compute the permissions

If you're unsure which octal value to use, try the calculator:

Use the chmod calculator

Next steps

chmod fixes permissions on files that already exist. To set the permissions the system uses when creating new files and directories, its complement is umask. Read the umask guide to understand the formula and the typical values (022, 027, 077), or jump straight to the umask calculator to confirm which modes new files and directories will receive.

To keep both calculators within reach, the Linux permissions hub groups chmod and umask with cheat sheets and examples.

Frequently asked questions

What does chmod 755 mean?
The owner gets rwx (read, write and execute = 7), and both group and others get r-x (read and execute = 5). It's the typical value for directories and executable scripts that should be browsable and runnable, but only the owner can modify them.
Why is chmod 777 dangerous?
It grants rwx to owner, group and others. Any user on the system (including a compromised process) can read, modify and execute the file. On servers with multiple users or services exposed to the internet, that's a serious security risk. Use the least-privilege value.
What's the difference between octal and symbolic permissions?
Octal permissions (e.g. 755) are a number encoding the three rwx bits per audience. Symbolic ones (e.g. u+x) modify existing permissions incrementally. Octal is more expressive when setting absolute permissions; symbolic is handy for adding or removing specific bits.
What permissions does a script need to run?
The execute bit (x) for whichever audience will launch it. For a personal script, `chmod u+x script.sh` or `chmod 700 script.sh` works. For a public read-and-execute script, `chmod 755 script.sh`. The owner still needs r so the shell can read the script's contents.
What are setuid, setgid and sticky?
Extra special bits. setuid (4xxx) makes the executable run as its owner. setgid (2xxx) does the same with the group, or forces group inheritance on directories. The sticky bit (1xxx) on a directory prevents users from deleting files that belong to other users (typical on /tmp).
What's the difference between chmod 755 and 777?
755 grants rwx to the owner and r-x to group and others, while 777 grants rwx to everyone. With 755, only the owner can modify the file and the rest can read and execute it. With 777, any user or process on the system can modify it, which is almost always a security risk. For directories or public executable scripts, 755 is the typical value.
What does chmod 644 mean?
644 is rw-r--r--: the owner reads and writes, group and others only read. It's the typical value for static files that everyone should read but only the owner should change: HTML, CSS, images, config files. It does not include the execute bit, so it doesn't work for scripts.
What does chmod 750 mean?
750 is rwxr-x---: owner with rwx, group with r-x, others denied. Useful when only your team group should execute a script or enter a directory, keeping the rest of the system out. Stricter than 755 without breaking team workflows.