Linux command
chgrp 命令
文件
复制后可按需替换文件名、目录或参数。
常用示例
Change the group of a file
chgrp [group] [path/to/file]
Change the group of a directory recursively
chgrp -R [group] [path/to/directory]
Change group using a reference file
chgrp --reference=[path/to/reference_file] [path/to/file]
Change group of a symbolic link itself
chgrp -h [group] [path/to/symlink]
Change group verbosely showing each file processed
chgrp -v [group] [path/to/file]
Change group showing only when changes are made
chgrp -c [group] [path/to/file]
说明
chgrp changes the group ownership of each specified file to the given group. The group can be specified by name or numeric GID. All files in Linux belong to both an owner and a group. While chown changes user ownership, chgrp specifically handles group ownership changes.
参数
- -c, --changes
- Report only when a change is made (like verbose but quieter)
- -f, --silent, --quiet
- Suppress most error messages
- -v, --verbose
- Output a diagnostic for every file processed
- -h, --no-dereference
- Affect symbolic links instead of referenced files
- -R, --recursive
- Operate on files and directories recursively
- --reference=_RFILE_
- Use RFILE's group instead of specifying a GROUP
FAQ
What is the chgrp command used for?
chgrp changes the group ownership of each specified file to the given group. The group can be specified by name or numeric GID. All files in Linux belong to both an owner and a group. While chown changes user ownership, chgrp specifically handles group ownership changes.
How do I run a basic chgrp example?
Run `chgrp [group] [path/to/file]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -c, --changes do in chgrp?
Report only when a change is made (like verbose but quieter)