【发布时间】:2020-07-15 01:36:50
【问题描述】:
这个命令在 Linux 终端有什么作用?
chmod -r /home/daria/photos/
我收到这个问题是因为没有错误
【问题讨论】:
标签: linux ubuntu unix terminal chmod
这个命令在 Linux 终端有什么作用?
chmod -r /home/daria/photos/
我收到这个问题是因为没有错误
【问题讨论】:
标签: linux ubuntu unix terminal chmod
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 的手册页没有解释这一点,这对一些用户来说很困难,但一旦你知道这一点,你就不能不知道这一点:)
【讨论】: