This is a quick one, how to change permissions recursively on directories or files. Say you want to change the permission on all directories under /home/username to 775 and all files to 664. All you need to do is issue the following commands:
For directories:
1.
find
/home/username/* -
type
d -
exec
chmod
775 {} \;
For files:
1.
find
/home/username/* -
type
f -
exec
chmod
664 {} \;
The lines above should be pretty self explanatory:
find – search for files in a directory hierarchy
path (/home/username) – the file or directory path
type – d for directory or f for file
-exec – execute the following command
chmod xxx – new file/directory permission level
braces {} – These 2 are replaced for the file/folder name at run-time
\; – this is how we close the command
More options can be found by typing man find on the command line.
I hope this short tutorial has helped you some. Thank you for stopping by and please share with others, after all, code should be free.