我在 /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
当移动test.txt
到不同的目录时,一切都按预期工作。
/tmp
是通过以下选项通过 fstab 安装的 tmpfs:
tmpfs /tmp tmpfs nodev,nosuid,size=5G 0 0
运行ls -l /
时,tmp 文件夹如下所示:
drwxrwxrwt 20 root root 640 26. Feb 12:01 tmp/
我正在运行 Manjaro,一个 Arch Linux 衍生产品。
我在安装 tmpfs 时做错了吗?