我在 /tmp 目录中遇到了奇怪的行为。虽然属于一个组的用户有权限读取/写入文件,他不能这样做。
在这个例子中,我/tmp/test.txt以 user 的身份创建了一个新文件max。我给它777组的权限,使该文件所属的组root,但用户root仍无法对其进行编辑。
su max
touch /tmp/test.txt
chmod 777 /tmp/test.txt
su root
chown max:root /tmp/test.txt
# ls -l /tmp/test.txt
-rwxrwxrwx 1 max root 0 26. Feb 12:08 test.txt
# echo "foobar" > /tmp/test.txt
bash: /tmp/test.txt: Permission denied
Run Code Online (Sandbox Code Playgroud)
当移动test.txt到不同的目录时,一切都按预期工作。
/tmp 是通过以下选项通过 fstab 挂载的 tmpfs:
tmpfs /tmp tmpfs nodev,nosuid,size=5G 0 0
Run Code Online (Sandbox Code Playgroud)
运行时ls -l /,tmp 文件夹如下所示:
drwxrwxrwt 20 root root 640 26. Feb 12:01 tmp/
Run Code Online (Sandbox Code Playgroud)
我正在运行 Manjaro,它是 Arch …