chmod -R applies a mode to a directory and everything inside it:
chmod -R u+rwX,go-w ~/proj
The trap: chmod -R 755 breaks nothing, chmod -R 644 breaks everything
The naive recursive command is chmod -R 755 dir or chmod -R 644 dir. The second is a disaster: it strips the execute bit from directories, and a directory without execute cannot be entered. Suddenly you cannot cd into your own folders or reach the files inside, even though you can see the names.
The reason is that numeric modes apply the same nine bits to files and directories alike, but directories need the execute bit and regular files usually should not have it.
The fix: capital X
chmod has a special mode X (capital) that means "execute, but only for directories and files that are already executable". It is exactly what recursive operations want:
# Owner full access; group/other read; directories stay traversable; plain files don't become executable
chmod -R u=rwX,go=rX ~/projX adds the execute bit to directories (so they stay enterable) and to files that already had execute (so scripts keep working), but it does not make every text file executable. This is the single most useful chmod fact most people never learn.
Better still: target files and directories separately
When you want precise control, use find to split the two:
find ~/proj -type d -exec chmod 755 {} + # directories: 755
find ~/proj -type f -exec chmod 644 {} + # files: 644-type d matches directories, -type f matches regular files, so each gets the mode that actually fits it. This is the bulletproof version for a web root or a release artifact. For more on the find side, see find files by owner, group, or permission.
FAQ
See also
- Linux file permissions explained: the rwx and octal model behind this.
- How to make a file executable (chmod +x): the single-file case.
- Find files by owner, group, or permission: the find -type split in depth.
- How to change file owner and group (chown): chown -R, the ownership equivalent.
Sources
Authoritative references this article was fact-checked against.





