语法:
以下是如何使用CHGRP命令的示例语法。
chgrp [OPTION]. GROUP FILE.
选项:
FILE. | 更改所有权的文件。如果文件尚不存在,则该命令将失败且未执行。 |
---|---|
-c, -changes | 使用-c或者-changes选项仅在更改时报告 |
-f, -silent, -quiet | 使用-f或者-silent,-quiet抑制大多数错误消息 |
-R, -recursive | 使用-r或者-rocurnurive选项递归地在文件和目录上运行 |
-v, -verbose | 使用-v或者-verbose选项输出处理的每个文件的诊断 |
-h, -help | 显示此帮助消息并退出 |
例子:
以下是如何在Ubuntu Linux上运行和使用CHGRP的一些示例。
如果要将名为Companical.txt的文件的所有权更改为组名称私有,则我们可以在下面运行命令。
chgrp Private Confidential.txt
如果要将/Office/Files目录中的所有文件和文件夹的组所有权更改为员工组,则我们可以运行以下命令:
chgrp -hR Staff /office/files
如果我们未登为root帐户,则可能必须使用sudo命令它。
chgrp -hR Staff /office/files
要更改整个目录的所有权和组,包括子目录,请添加-r选项。
使用--help选项查看帮助信息
Usage: chgrp [OPTION]. GROUP FILE. or: chgrp [OPTION]. --reference=RFILE FILE. Change the group of each FILE to GROUP. With --reference, change the group of each FILE to that of RFILE. -c, --changes like verbose but report only when a change is made -f, --silent, --quiet suppress most error messages -v, --verbose output a diagnostic for every file processed --dereference affect the referent of each symbolic link (this is the default), rather than the symbolic link itself -h, --no-dereference affect symbolic links instead of any referenced file (useful only on systems that can change the ownership of a symlink) --no-preserve-root do not treat '/' specially (the default) --preserve-root fail to operate recursively on '/' --reference=RFILE use RFILE's group rather than specifying a GROUP value -R, --recursive operate on files and directories recursively The following options modify how a hierarchy is traversed when the -R option is also specified. If more than one is specified, only the final one takes effect. -H if a command line argument is a symbolic link to a directory, traverse it -L traverse every symbolic link to a directory encountered -P do not traverse any symbolic links (default) --help display this help and exit --version output version information and exit Examples: chgrp staff /u Change the group of /u to "staff". chgrp -hR staff /u Change the group of /u and subfiles to "staff".
关于chgrp命令:
用户使用CHGRP命令更改Linux文件系统上的文件和文件夹的组所有权。
它允许超级用户更改和限制对文件和目录的访问。
日期:2020-07-07 20:55:58 来源:oir作者:oir