Changing permissions of just files or just directories recursively

June 22, 2011

Sometimes you just want to change the permissions of all the fiels or all the directories under a certain folder. For example, when wanting to set the sticky bit on just directories on all directories under a folder.

Here we combine the find command with chmod …

find /path/to/someDirectory -type d -print0 | xargs -0 chmod g+s

And for just files (for when you forget that chmod -R g+s is applied to everything)…

find /path/to/someDirectory -type f -print0 | xargs -0 chmod g-s


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

%d bloggers like this: