【发布时间】:2010-11-02 16:51:53
【问题描述】:
为什么可以touch 写保护文件?
下面不应该报错吗?
$ touch test.txt
$ chmod a-w test.txt
$ ls -l test.txt
-r--r--r-- 1 name group 0 Jun 13 09:14 test.txt
$ touch test.txt && echo OK
OK
$ ls -l test.txt
-r--r--r-- 1 name group 0 Jun 13 09:15 test.txt
touch 是否更改权限、触摸文件并更改权限?为什么要这么做?
鉴于这种行为,如果我真的想保护文件,以便我(我的用户)将来永远不会(无意)更改、删除或更改其时间戳,我该怎么做?
(抱歉,不是严格与编程相关,但有一点点,可能很多程序员都会感兴趣。)
【问题讨论】:
-
在我看来,这听起来像是一个更适合 serverfault.com 的问题。
-
这样做时时间戳会改变吗?
-
是的。添加了上面更改的时间戳。
标签: linux permissions touch