16.3 为什么chmod不能更改符号连接的权限?

2009-05-13 04:49:01来源:未知 阅读 ()

新老客户大回馈,云服务器低至5折

16.3 为什么chmod不能更改符号连接的权限?
符号连接没有权限,而且在默认情况下,chmod不会追踪符号连接去改变目标文件的权限。因此如果你有
一个文件,foo 和到这个文件的一个符号连接bar,下面这个命令是可以的:
%chmod g-w bar
但是,foo文件的权限并不会因此而改变。
如果真的需要这么做,你需要使用选项-H 或-L与-R一起使用。更多信息参考手册上的 chmod(1)或者
symlink页。
警告:-R 选项将使得chmod有递归的功能。 一定要仔细为chomod指定目录或者指向目录的符号连接。如
果你想改变被一个符号连接引用的目录的权限,使用不带任何选项的chmod并且在符号连接末尾加上一个
斜线(/)。如:假设foo是一个到bar目录的符号连接,你要改变foo的权限(事实是bar),你可以这样:
% chmod 555 foo/
有了末尾的斜线,chmod(1)将追踪符号连接foo去改变目录bar的权限。

PS 原文
16.3. Why will chmod not change the permissions on symlinks?
Symlinks do not have permissions, and by default,
chmod(1)
will not follow symlinks to change the permissions on the target file. So if you have a file, foo, and a symlink to that file, bar, then this command will always succeed.
% chmod g-w bar
However, the permissions on foo will not have changed.
You have to use either -H or -L together with the -R option to make this work. See the
chmod(1)
and
symlink(7)
manual pages for more info.
警告: The -R option does a RECURSIVE
chmod(1)
. Be careful about specifying directories or symlinks to directories to
chmod(1)
. If you want to change the permissions of a directory referenced by a symlink, use
chmod(1)
without any options and follow the symlink with a trailing slash (/). For example, if foo is a symlink to directory bar, and you want to change the permissions of foo (actually bar), you would do something like:
% chmod 555 foo/
With the trailing slash,
chmod(1)
will follow the symlink, foo, to change the permissions of the directory, bar.


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/18248/showart_183353.html

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:16.2 为什么top显示很少的的空闲内存即使我运行很少的程序?

下一篇:16.4 我能在FreeBSD下运行DOS的二进制文件吗?