【问题标题】:What does the following Chmod command do? [closed]下面的 Chmod 命令有什么作用? [关闭]
【发布时间】:2012-09-12 16:33:41
【问题描述】:

我在下一页遇到了一个命令。 http://alblue.bandlem.com/2011/07/setting-up-google-code-with-git.html

chmod go=.netrc

在 chmod 中找不到。

【问题讨论】:

  • 如果您使用的是 GNU chmod(例如,在 linux 上),手册页的描述部分有一个非常清晰简洁的描述,使用了符号模式,信息手册有完全相同的示例给了。如果您使用的是 BSD chmod(例如,在 Mac 上),则手册页的“有效模式示例”部分与您给出的示例完全相同。

标签: macos terminal command chmod


【解决方案1】:

chmod go= .netrc 无法访问组和其他人对文件.netrc
chmod go=rx .netrc 授予读取和执行访问权限`

基本上,您可以添加+,减去- 并分配= 某些访问级别。

查看this link

【讨论】:

    【解决方案2】:

    来自 chmod 手册页中的“有效模式示例”:

    go= 清除组和其他人的所有模式位。

    【讨论】:

    • 这部分手册页在 GNU 版本中不存在——但手册页顶部有一个非常清晰的解释,示例 确实 存在于信息手册。所以,这是一个很好的答案。
    【解决方案3】:

    这意味着“绝对设置这些权限”。在这种情况下,您将清除文件.netrc 上的go 权限(因为您没有在等号后命名任何权限)。

    如果你做了类似的事情:

    chmod go=r .netrc

    您将向groupother 授予read 权限,但清除go 的所有其他权限。

    这里有一些例子:

    ~> pico test.txt <-- Create a file with default permissions
    ~> ls -l test.txt
    -rw-r--r--  1 mike  staff  7 Sep 12 09:39 test.txt
    ~> chmod go= test.txt <-- Clear the permissions on g and o
    ~> ls -l test.txt
    -rw-------  1 mike  staff  7 Sep 12 09:39 test.txt
    ~> chmod go=r test.txt <-- Set only read on g and o
    ~> ls -l test.txt
    -rw-r--r--  1 mike  staff  7 Sep 12 09:39 test.txt
    ~> chmod o=rw test.txt <-- Set read and write only on o
    ~> ls -l test.txt
    -rw-r--rw-  1 mike  staff  7 Sep 12 09:39 test.txt
    

    有关更多信息,请参阅符号模式下的man 页面。

    【讨论】:

      猜你喜欢
      • 2020-07-15
      • 1970-01-01
      • 2017-04-18
      • 1970-01-01
      • 1970-01-01
      • 2013-04-02
      • 2016-03-12
      • 2020-03-15
      • 1970-01-01
      相关资源
      最近更新 更多