Dev Basics · 5 min read
chmod Explained: 644 vs 755 and Unix Permissions
If you have ever run chmod 755 without fully knowing why, this guide is for you. Unix permissions are simpler than they look once you understand the read/write/execute model and the numbers that represent it.
We will cover who permissions apply to, how the octal numbers are built, and the handful of values you will use day to day.
Try it yourself with the related tool.
Calculate chmod permissions →Advertisement
Three groups, three permissions
Every file has permissions for three groups: the owner (user), the group, and others (everyone else). Each group can be granted read (r), write (w), and execute (x). So a full permission set looks like rwxr-xr-x: the owner can read, write, and execute; group and others can read and execute.
How the numbers work
Each permission has a value: read is 4, write is 2, execute is 1. You add them per group to get a single digit. So 7 is read+write+execute (4+2+1), 5 is read+execute (4+1), and 6 is read+write (4+2). Three digits — one per group — make a full mode like 755 or 644.
644 vs 755
644 gives the owner read and write, and everyone else read only — the right default for regular files like documents and web assets. 755 adds execute for all three groups, which directories need to be entered and scripts need to be run. Using 755 on a plain data file just adds a needless execute bit.
Locking things down: 600 and 700
600 gives only the owner read and write, with no access for anyone else — ideal for private files such as SSH keys. 700 does the same for directories. When in doubt for something sensitive, prefer the most restrictive mode that still works.
