Andy Regan Ramblings of an Irish Sysadmin

25Feb/100

Quickly Reset Linux File and Directory Permissions

Just a quick post so I can keep these commands handy (since I keep forgetting them). These will allow you to quickly set different permissions for all files (or all folders) within a specific directory in Linux.

Reset File Permissions

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

Reset Directory Permissions

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

Reset Permissions on 777 PHP Files Only

$find /path/to/directory/ -name \*.php -perm 777 -type f -exec chmod 644 {} \;