【问题标题】:Difference between using "chmod a+x" and "chmod 755" [closed]使用“chmod a+x”和“chmod 755”之间的区别[关闭]
【发布时间】:2013-09-06 22:52:56
【问题描述】:

这听起来可能很傻,但我有一个需要运行的文件/脚本,为了做到这一点,我必须将其更改为可执行。我想使用chmod a+xchmod 755。但是使用chmod a+xchmod 755有区别吗?

【问题讨论】:

  • chmod 是更改模式的缩写。 chmod [references][operator][modes] file a+x 意思是a -> all(owner,group and other)

标签: linux unix chmod


【解决方案1】:

chmod a+x 修改参数的模式,而chmod 755 设置它。在具有完整权限或没有权限的情况下尝试这两种变体,您会注意到不同之处。

【讨论】:

  • 一个修改一个设置。解释得很好!
  • ls -llh 临时文件 --> -rwerwerwe ............. chmod 755 临时文件 --> -rwer-er-e ........ .. 但是 chmod a+x tempfile --> -rwerwerwe
  • 也就是说chmod a+x读取权限,然后写入,而chmod 755只写入。
【解决方案2】:

是的 - 不同

chmod a+x 会将 exec 位添加到文件中,但不会触及其他位。例如,othersgroup 可能仍然无法读取文件。

chmod 755 将始终使用 perms 755 创建文件,无论初始权限是什么。

这可能对您的脚本很重要,也可能无关紧要。

【讨论】:

  • 这应该是公认的答案
【解决方案3】:

确实有。

chmod a+x 与当前状态相关,只是设置了x 标志。所以一个 640 的文件变成了 751(或 750?),一个 644 的文件变成了 755。

chmod 755,然而,将掩码设置为:rwxr-xr-x,不管以前是怎样的。相当于chmod u=rwx,go=rx

【讨论】:

    猜你喜欢
    • 2013-11-02
    • 2018-11-17
    • 2019-01-19
    • 2015-01-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多