Kis*_*ada 2 permissions symlink
我实际上是开始学习 Unix 的,在学习的过程中,我一直呆在这里。虽然这可能看起来很愚蠢的问题我实际上不清楚所以请帮助我。
我有一个文件作为 somefile.txt 和一个引用 的符号链接somefile.txt
,我发现两者的默认权限都是rw-r--r--
.
当我更改somefile.txt
( chmod ugo=rwx somefile.txt
) 的权限时,我发现两个文件中的rwxrwxrwx
. 但是当我尝试通过 give 更改权限时chmod u-rx somefile.txt
,我发现更改仅somefile.txt
在符号链接中而不是在符号链接中。我想知道为什么?我正在使用 RedHat cygwin。
您至少弄错了一个命令的输出。符号链接的权限总是rwxrwxrwx
,或者说它们根本没有权限:
$ touch file
$ ls -l
total 0
-rw-rw-r-- 1 muru muru 0 Dec 5 20:53 file
$ ln -s file link
$ ls -l
total 0
-rw-rw-r-- 1 muru muru 0 Dec 5 20:53 file
lrwxrwxrwx 1 muru muru 4 Dec 5 20:53 link -> file
$ chmod a+x file
$ ls -l
total 0
-rwxrwxr-x 1 muru muru 0 Dec 5 20:53 file
lrwxrwxrwx 1 muru muru 4 Dec 5 20:53 link -> file
Run Code Online (Sandbox Code Playgroud)
有关更多信息,请参阅此FreeBSD 常见问题解答。
既然你在 Linux 上,man chmod
说:
chmod never changes the permissions of symbolic links; the chmod system
call cannot change their permissions. This is not a problem since the
permissions of symbolic links are never used. However, for each
symbolic link listed on the command line, chmod changes the permissions
of the pointed-to file. In contrast, chmod ignores symbolic links
encountered during recursive directory traversals.
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
401 次 |
最近记录: |