chmod -R 775 *.cgi
只更改当前目录中文件的权限,子目录中的文件根本不会被修改。这与简单地执行 chmod 775 *.cgi
的功能完全相同。我见过人们使用诸如 find
之类的解决方案。很好,但是如果 -R 模式什么都没有完成,为什么还要存在呢?
最佳答案
可能是因为您没有名为*.cgi
的目录。 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.
例如:
$ 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
关于bash - 为什么 chmod 上的递归模式除了递归之外什么都做?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3472383/