How to use the Linux find command
04/01/2009
I always have trouble remembering how to use the find command in Linux, so here are a few examples.
Finding all hidden files:
find . -regex '.*/\..*'
Deleting all Java files:
rm -rf `find . -name *.java`
Deleting all directories named .svn:
rm -rf `find . -type d -name .svn`
Recursively set permissions for a web server:
chmod -R a+r ~/www
find ~/www -type d -exec chmod a+x {} \;
Finding all exectuable files:
find . -executable -type f
Wouldn’t be better suppling the simplistic chmod way, like this?
chmod -R 777 /path/to/directory
Which is equal to:
chmos -R a=rwx /path/to/directory
Regards!
That would make everything readable, writable, and executable by everyone. A preferable approach would be to add read permissions only for the web server.