{
    "mode": "info",
    "parameter": "chgrp",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/info/chgrp/json",
    "generated": "2026-07-29T00:42:26Z",
    "sections": {
        "File: coreutils.info,  Node: chgrp invocation,  Next: chmod invocation,  Prev: chown invocation,  Up: Changing file attributes": {
            "content": "",
            "subsections": [
                {
                    "name": "13.2 'chgrp': Change group ownership",
                    "content": "'chgrp' changes the group ownership of each given FILE to GROUP (which\ncan be either a group name or a numeric group ID) or to the group of an\nexisting reference file.  *Note chown invocation::.  Synopsis:\n\nchgrp [OPTION]... {GROUP | --reference=REFFILE} FILE...\n\nIf GROUP is intended to represent a numeric group ID, then you may\nspecify it with a leading '+'.  *Note Disambiguating names and IDs::.\n\nIt is system dependent whether a user can change the group to an\narbitrary one, or the more portable behavior of being restricted to\nsetting a group of which the user is a member.\n\nThe program accepts the following options.  Also see *note Common\noptions::.\n\n'-c'\n'--changes'\nVerbosely describe the action for each FILE whose group actually\nchanges.\n\n'-f'\n'--silent'\n'--quiet'\nDo not print error messages about files whose group cannot be\nchanged.\n\n'--dereference'\nDo not act on symbolic links themselves but rather on what they\npoint to.  This is the default when not operating recursively.\n\nCombining this dereferencing option with the '--recursive' option\nmay create a security risk: During the traversal of the directory\ntree, an attacker may be able to introduce a symlink to an\narbitrary target; when the tool reaches that, the operation will be\nperformed on the target of that symlink, possibly allowing the\nattacker to escalate privileges.\n\n'-h'\n'--no-dereference'\nAct on symbolic links themselves instead of what they point to.\nThis mode relies on the 'lchown' system call.  On systems that do\nnot provide the 'lchown' system call, 'chgrp' fails when a file\nspecified on the command line is a symbolic link.  By default, no\ndiagnostic is issued for symbolic links encountered during a\nrecursive traversal, but see '--verbose'.\n\n'--preserve-root'\nFail upon any attempt to recursively change the root directory,\n'/'.  Without '--recursive', this option has no effect.  *Note\nTreating / specially::.\n\n'--no-preserve-root'\nCancel the effect of any preceding '--preserve-root' option.  *Note\nTreating / specially::.\n\n'--reference=REFFILE'\nChange the group of each FILE to be the same as that of REFFILE.\nIf REFFILE is a symbolic link, do not use the group of the\nsymbolic link, but rather that of the file it refers to.\n\n'-v'\n'--verbose'\nOutput a diagnostic for every file processed.  If a symbolic link\nis encountered during a recursive traversal on a system without the\n'lchown' system call, and '--no-dereference' is in effect, then\nissue a diagnostic saying neither the symbolic link nor its\nreferent is being changed.\n\n'-R'\n'--recursive'\nRecursively change the group ownership of directories and their\ncontents.\n\n'-H'\nIf '--recursive' ('-R') is specified and a command line argument is\na symbolic link to a directory, traverse it.  *Note Traversing\nsymlinks::.\n\n'-L'\nIn a recursive traversal, traverse every symbolic link to a\ndirectory that is encountered.\n\nCombining this dereferencing option with the '--recursive' option\nmay create a security risk: During the traversal of the directory\ntree, an attacker may be able to introduce a symlink to an\narbitrary target; when the tool reaches that, the operation will be\nperformed on the target of that symlink, possibly allowing the\nattacker to escalate privileges.\n\n*Note Traversing symlinks::.\n\n'-P'\nDo not traverse any symbolic links.  This is the default if none of\n'-H', '-L', or '-P' is specified.  *Note Traversing symlinks::.\n\nAn exit status of zero indicates success, and a nonzero value\nindicates failure.\n\nExamples:\n\n# Change the group of /u to \"staff\".\nchgrp staff /u\n\n# Change the group of /u and subfiles to \"staff\".\nchgrp -hR staff /u\n"
                }
            ]
        }
    },
    "flags": [],
    "examples": [],
    "see_also": []
}