Why does recursive mode on chmod do everything except recursion?

chmod -R 775 *.cgionly changes permissions on files in the current directory, files in a subdirectory do not change at all. This is exactly the same functionality as simple execution chmod 775 *.cgi. I saw people using solutions like findthat and something else. OK, but why does the -R mode even exist if it doesn't do anything?

+3
source share
5 answers

Perhaps because you do not have directories with a name *.cgi. Enter the manual :

-R . , , chmod .

:

$ 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
+14

-R chmod , .

chmod -R 775 *.cgi, *.cgi , , - chmod - .

( , *.cgi...)

+7

, ,

find . -name '*.cgi' -print0 | xargs -0 chmod 755

find .cgi, , xargs, chmod .

+6

*.cgi , .cgi. chmod .

chmod , , , . , , , .

cgi chmod , :

find . -name '*.cgi' -print0 | xargs -0 chmod 775
+3

* - , -R - . chmod * .

Put the case where foo0.cgi and foo1.cgi are directory contents. If you type chmod -R o+r *.cgi, then it chmodtakes the characters -R, o + r, foo0.cgi and foo1.cgi as arguments.

What you want to do can be easily done:

find . -iname '*.cgi' | xargs chmod 755
+2
source

Source: https://habr.com/ru/post/1759424/


All Articles