命令中的点(.)是什么意思?

命令中的点(.)是什么意思?

这是我在教程中看到的命令:

mkswap /swap && chown root. /swap && chmod 0600 /swap && swapon /swap

这是什么.意思?

答案1

.在此上下文中,是的弃用形式,:是新所有者和组之间的分隔符。

info chown

   Some older scripts may still use ‘.’ in place of the ‘:’ separator.
POSIX 1003.1-2001 (*note Standards conformance::) does not require
support for that, but for backward compatibility GNU ‘chown’ supports
‘.’ so long as no ambiguity results.  New scripts should avoid the use
of ‘.’ because it is not portable, and because it has undesirable
results if the entire OWNER‘.’GROUP happens to identify a user whose
name contains ‘.’.

因此,在这种情况下,它与 相同chown root: /swap,这又意味着

OWNER:
     If a colon but no group name follows OWNER, that user is made the
     owner of the files and the group of the files is changed to OWNER’s
     login group.

由于 root 的登录组是root,因此相当于chown root:root /swap

答案2

这是

sudo chown root:root /swap

因为它会将组设置为与用户名相同。

尝试创建一个文件夹,然后以相同方式将所有权设置为 root,然后完成后,尝试将所有权设置为您的用户名。

sudo chown $USER. folder/

希望这有帮助!

相关内容