【发布时间】:2014-10-18 22:58:23
【问题描述】:
我需要将文件 chown 给其他用户,并确保它再次无法读取。听起来很复杂,但主要是这样的:
cd /readonly
wget ...myfile
cd /workdir
chmod -R 444 /readonly
chown -R anotheruser /readonly
ls /readonly # OK
echo 123 > /readonly/newfile # Should not be allowed
cat /readonly/myfile # OK
chown 777 /readonly # Should not be allowed
在 SunOS 中我看到了类似的东西,我记得无法删除 Apache 删除的文件,但我在 Linux 中找不到类似的东西,因为 chmod 需要 root 权限。
我需要这个的原因是,我将从网络上获取一些文件,确保它们不会被脚本的其余部分更改,只有 root 可以更改它。该脚本不能以 root 身份运行。
【问题讨论】:
-
也许unix.stackexchange.com 会是一个更好的地方来问这个问题
-
如果您的文件系统支持,您可以尝试使用
chattr +i。
标签: linux bash permissions file-permissions