published on
tags: linux osx permissions

change permissions recursively

Sometime you may need to execute a command recursively on certain type of object. For example you may need to change permissions to all files in the current directory and all subdirectories but not the directories. Therefore you can use the find utility.

changing only file permissions

find . -type f -exec chmod 600 {} \;

same for directories

find . -type d -exec chmod 700 {} \;

other useful find tricks

you can execute nearly every command on everything that find can match. this for example will delete all files down the tree starting at the current directory which are older than 7 days but it wont touch the directory structure

find . -ctime +7d -type f -exec rm -v {} \;

happy finding 😉