views:

5269

answers:

4

I want to recursively chmod all of the subdirectories below my calcium directory:

chmod a+wx calcium

How do I change the above command to do this?

I believe I'm using bash shell although I'm not sure how to verify this.

+9  A: 
chmod -R <whatever>
dirkgently
Cool! Thanks .
Yen
As xkcd150 mentioned in a later answer, this will chmod *everything*. Not just subdirectories as the question specifies.
Danny
Sure, it is. But it isn't terribly useful to only have write/execute on the directory but not the contents. Which is why I use this form.
dirkgently
+1  A: 

chmod -R a+wx calcium

Jarek
+1  A: 
$ echo $SHELL

should tell you what shell you are using. But that likely doesn't matter, since chmod is an executable that any shell would call just the same.

Jeremy Huiskamp
Thanks. It's bash .
Yen
+12  A: 

chmod -R is going to do it on everything, not just directories.

To target only directories you can use find + xargs

find calcium/ -type d | xargs chmod a+wx
xkcd150
find has a -exec. Use it. It's not bugged like xargs is. (xargs is bugged for filenames containing spaces and quote characters unless you use the -0 option and use find's -print0 to feed it NULL-separated data). Use this instead: find foo/ -type d -exec chmod a+wx {} \;
lhunath
nice, i'll be trying that out instead
xkcd150
`find .... -print0 | xargs -0 ....`. find's -exec is nice, but it can lead to a horrible amount of fork/execs. (I've used computers and workloads where xargs turned an unusably-slow system into a tolerable system.)
sarnold

related questions