【问题标题】:What does the following command: chmod -r?下面的命令是什么:chmod -r?
【发布时间】:2020-07-15 01:36:50
【问题描述】:

这个命令在 Linux 终端有什么作用?

chmod -r /home/daria/photos/

我收到这个问题是因为没有错误

【问题讨论】:

    标签: linux ubuntu unix terminal chmod


    【解决方案1】:

    chmod 是一个用于更改文件或目录的permissions 的实用程序。可以使用ls -l /path/to/file命令观察chmod的变化。

    ❯ echo "XYZ" > /tmp/abc   # Create a new file named abc
    
    ❯ l /tmp/abc              # List the permissions of /tmp/abc
    -rw-r--r--  1 abdulkarim  wheel     4B Apr  3 13:17 /tmp/abc
    
    ❯ cat /tmp/abc            # Display the contents of the file
    XYZ
    
    ❯ chmod -r /tmp/abc       # remove read permissions for User, Group and Others
    
    ❯ l /tmp/abc              # Notice the read perms are gone
    --w-------  1 abdulkarim  wheel     4B Apr  3 13:17 /tmp/abc
    
    ❯ cat /tmp/abc            # We can no longer cat the file!
    cat: /tmp/abc: Permission denied
    

    因此,命令chmod -r /path/to/file 将撤销所有人的读取权限。同样chmod +r 将授予所有人读取权限。

    chmod 的手册页没有解释这一点,这对一些用户来说很困难,但一旦你知道这一点,你就不能不知道这一点:)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-03-25
      • 1970-01-01
      • 1970-01-01
      • 2013-07-29
      • 1970-01-01
      • 1970-01-01
      • 2021-06-02
      • 2010-10-16
      相关资源
      最近更新 更多