Joh*_*n K 18 permissions chown
有什么区别:
sudo chown $USER:$USER
Run Code Online (Sandbox Code Playgroud)
和
sudo chown $USER
Run Code Online (Sandbox Code Playgroud)
为什么是2次?一个用户有错吗?当我查看权限时namei -l
,我经常看到类似root root
或的内容proxy proxy
。
为什么必须定义和列出所有者 2 次?
May*_*hux 21
chown 命令用于更改文件或目录的所有者和组所有者。使用此命令需要超级用户权限。chown 的语法如下所示:
chown [owner][:[group]] file...
Run Code Online (Sandbox Code Playgroud)
chown 可以根据命令的第一个参数更改文件所有者和/或文件组所有者。这里有些例子:
chown owner file
例子:
chown bob file --> Changes the ownership of the file from its current owner to user bob.
Run Code Online (Sandbox Code Playgroud)
chown owner:group file
例子:
chown bob:users file --> Changes the ownership of the file from its current owner to user bob and changes the file group owner to group users.
Run Code Online (Sandbox Code Playgroud)
chown :group file
例子:
chown :admins file --> Changes the group owner to the group admins. The file owner is unchanged.
Run Code Online (Sandbox Code Playgroud)
chown owner: file
例子:
chown bob: file --> Change the file owner from the current owner to user bob and changes the group owner to the login group of user bob.
Run Code Online (Sandbox Code Playgroud)
请阅读这个不错的教程https://www.linode.com/docs/tools-reference/linux-users-and-groups。这会显示有关用户、组、权限等的一些信息...
不是user:user
,而是user:group
。
这是命令格式
chown [OPTION]... [OWNER][:[GROUP]] FILE...
用户组可能包括许多用户。以下是有关组的一些信息:
Linux 使用组作为组织用户的一种方式。组组织帐户集合,主要是作为一种安全措施。组成员的控制是通过 /etc/group 文件管理的,该文件显示了组及其成员的列表。每个用户都有一个默认组或主要组。当用户登录时,将为其主要组设置组成员资格。这意味着当用户启动程序或创建文件时,文件和正在运行的程序都将与用户的当前组成员身份相关联。用户可以访问其他组中的其他文件,只要他们也是该组的成员并且设置了访问权限。要在不同的组中运行程序或创建文件,用户必须运行 newgrp 命令来切换他们当前的组。
文件归用户和组所有。默认情况下,它由创建文件的用户及其默认组拥有,除非它被更改。
在您的情况下, userroot
是 group 的成员root
。