chmod -R 775 *.cgi
only changes permissions on the files in the current directory, the files in the subdirectory don't get modified at all. This is the exact same functionality as simply doing chmod 775 *.cgi
. I have seen people use solutions such as with find
and whatnot. Ok great, but why does -R mode even exist if it doesn't even accomplish anything?
Probably because you have no directories named *.cgi
. Quoth the manual:
-R Recursively change file mode bits. For each file operand that names a directory, chmod shall change the file mode bits of the directory and all files in the file hierarchy below it.
For example:
$ ls -R
.:
a a.c b.c c.c
./a:
a.c b.c sub
./a/sub:
a.c b.c
$ chmod -R 444 *.c
$ ls -l
drwxr-xr-x 3 msw msw 4096 2010-08-12 18:07 a
-r--r--r-- 1 msw msw 0 2010-08-12 18:07 a.c
-r--r--r-- 1 msw msw 0 2010-08-12 18:07 b.c
-r--r--r-- 1 msw msw 0 2010-08-12 18:07 c.c
$ : directory a not affected
$ chmod -R u-w a
$ ls -l a
-r-xr-xr-x 1 msw msw 0 2010-08-12 18:07 a.c
-r-xr-xr-x 1 msw msw 0 2010-08-12 18:07 b.c
dr-xr-xr-x 3 msw msw 4096 2010-08-12 18:07 sub
$ ls -l a/sub
-r-xr-xr-x 1 msw msw 0 2010-08-12 18:07 a.c
-r-xr-xr-x 1 msw msw 0 2010-08-12 18:07 b.c
$ : got em