+64-3-3595735

Home » Linux » Reset permissions for files and folders in Linux / Bash

Reset permissions for files and folders in Linux / Bash

Three simple command lines to sort out folder and file permission and ownership issues in Linux.
The reason for using two different commends for the files and folders is you don’t want executable bit set on files (unless you plan on running it) and folders don’t work well without it.

To change all the directories to 755 (drwxr-xr-x):

find /path/to/folder -type d -exec chmod 755 {} \;

To change all the files to 644 (-rw-r--r--):

find /path/to/folder -type f -exec chmod 644 {} \;

To change all the files and folders be owned by username:

sudo chown -Rv username:username /path/to/folder