Toolman

Chmod permission values

What each permission value actually grants, and when it is the right one. Use the calculator to build a value from checkboxes.

OctalSymbolicOwnerGroupOthers
000---------no accessno accessno access
400r--------readno accessno access
440r--r-----readreadno access
444r--r--r--readreadread
600rw-------read, writeno accessno access
640rw-r-----read, writereadno access
644rw-r--r--read, writereadread
660rw-rw----read, writeread, writeno access
664rw-rw-r--read, writeread, writeread
666rw-rw-rw-read, writeread, writeread, write
700rwx------read, write, executeno accessno access
710rwx--x---read, write, executeexecuteno access
744rwxr--r--read, write, executereadread
750rwxr-x---read, write, executeread, executeno access
751rwxr-x--xread, write, executeread, executeexecute
754rwxr-xr--read, write, executeread, executeread
755rwxr-xr-xread, write, executeread, executeread, execute
764rwxrw-r--read, write, executeread, writeread
770rwxrwx---read, write, executeread, write, executeno access
774rwxrwxr--read, write, executeread, write, executeread
775rwxrwxr-xread, write, executeread, write, executeread, execute
776rwxrwxrw-read, write, executeread, write, executeread, write
777rwxrwxrwxread, write, executeread, write, executeread, write, execute
1777rwxrwxrwtread, write, executeread, write, executeread, write, execute
2755rwxr-sr-xread, write, executeread, executeread, execute
2775rwxrwsr-xread, write, executeread, write, executeread, execute
4755rwsr-xr-xread, write, executeread, executeread, execute
4711rws--x--xread, write, executeexecuteexecute
6755rwsr-sr-xread, write, executeread, executeread, execute

Reading a permission value

Each digit is the sum of the permissions granted to one class of user: 4 for read, 2 for write, 1 for execute. The three digits are the file's owner, its group, and everyone else, in that order. Because each digit covers exactly three bits, octal maps onto the permission bits one-to-one — which is why permissions are written in base 8 and not in decimal.

Files and directories are different

The same digit means different things depending on what it is applied to, and this is the single most common source of confusion:

BitOn a fileOn a directory
rRead the contentsList the names inside
wModify the contentsCreate, rename and delete entries
xRun it as a programEnter it and reach entries by name

Two consequences follow. A directory with read but no execute lets you see the names of files you cannot open. And write permission on a directory is enough to delete a file inside it even if you have no permission on the file itself — deletion is a change to the directory, not to the file. That is precisely the hole the sticky bit exists to close.

The defaults worth memorising

ValueUse
644Ordinary files — the owner edits, everyone reads
755Directories and executable scripts
600Secrets: keys, tokens, .env files
700Private directories such as ~/.ssh
775A directory a group maintains and others read
1777A shared scratch directory, sticky so nobody deletes another's files

Why recursive chmod usually goes wrong

chmod -R 755 on a project tree is a common instruction and an unhelpful one: it marks every source file executable, because a numeric mode makes no distinction between a file and a directory. The fix is the capital X in symbolic mode, which adds execute only to directories and to files that already had it somewhere:

chmod -R u=rwX,go=rX .

Read this as: give the owner read and write plus execute-where-appropriate, and give everyone else read plus execute-where-appropriate. Directories become 755 and ordinary files 644, in one pass.

umask decides what you get by default

New files are not created with the permissions you might expect, because the umask removes bits from a base value. The base is 666 for files and 777 for directories, and the umask is subtracted:

umaskNew fileNew directory
022644755
002664775
077600700

A umask of 022 is the common default, which is where 644 and 755 come from. Systems using per-user groups often default to 002, making new files group-writable — harmless when the group has one member, and a surprise when it does not.