Recursive chmod

When considering the chmod -R command, you may actually be wanting to descend, from some directory into all of its subdirectories to set the file permissions for a particular type of file. Directories should be 755, of course.

Try using:

$ find . -type f -print
$ find . -type f -name *.php -print

#1 will search the present working directory (.) for documents of type file (f) and print onto the standard output.
#2 will search the present working directory (.) for documents of type file (f), with filename ending with “.php” and print onto the standard output.

When you are satisfied that your find command is correct, add the xargs parameter to the end:

$ find -type f -print | xargs chmod 644

This will set file permissions in ALL subdirectories to be 644 or -rw-r–r–.

From support.daemonnews.org.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s