Bash Commands to Change Permissions on Nested Directories and Files

I needed to fix permissions on my personal home directory files. Don’t use it on / or /home without considering what other software you needs access to certain folders or files. You will potentially screw up your Linux install.

Change all directories to 755 (drwxr-xr-x)

find /home/example -type d -exec chmod 755 {} \;

Change all files to 644 (-rw-r--r--)

find /home/example -type f -exec chmod 644 {} \;
  • You can remove directories from consideration by adding a -prune some/dir -o before the command
  • You can also hunt down specific “broken” permissions to fix with -perm, e.g. if you typo’d 644 as 633, you can do find . -perm 633 -exec chmod 644 {} \;