{{Short description|Shell command for changing the group of a file}} {{lowercase title}} {{Infobox software | name = chgrp | logo = <!-- Image name is enough. --> | logo alt = | logo caption = | screenshot = Chgrp-example-command.gif | screenshot alt = | caption = Example usage of {{code|chgrp}} command to change the files' groups | collapsible = <!-- Any text here will collapse the screenshot. --> | author = | developer = AT&T Bell Laboratories | released = {{Start date and age|1975|5}}<!-- {{Start date and age|YYYY|MM|DD|df=yes/no}} --> | discontinued = <!-- Set to yes if software is discontinued, otherwise omit. --> | ver layout = <!-- simple (default) or stacked --> | latest release version = | latest release date = <!-- {{Start date and age|YYYY|MM|DD|df=yes/no}} --> | latest preview version = | latest preview date = <!-- {{Start date and age|YYYY|MM|DD|df=yes/no}} --> | repo = <!-- {{URL|example.org}} --> | programming language = Plan 9: C | operating system = Unix, Unix-like, Plan 9, Inferno, IBM i | platform = Cross-platform | size = | language = | language count = <!-- Number only --> | language footnote = | genre = Command | license = Plan 9: MIT License | alexa = | website = <!-- {{URL|example.org}} --> | standard = | AsOf = }}

'''{{code|chgrp}}''', short for '''ch'''ange '''gr'''ou'''p''', is a shell command for changing the group associated with a Unix-based file system file {{endash}} including special files such as directories. Changing the group of a file is restricted to a super-user (such as via {{code|sudo}}) or to the file's owning user if the user is in the specified group.

A file has access permissions for the owning user, a group and for others. Changing the group for a file changes access to it based on users' group memberships.

==History== The {{code|chgrp}} command was originally developed as part of the Unix operating system by AT&T Bell Laboratories. It is available in most Unix-like systems, Plan 9, Inferno and IBM i.<ref>{{cite web |title=IBM System i Version 7.2 Programming Qshell |language=en |author=IBM |website=IBM |author-link=IBM |url=https://www.ibm.com/support/knowledgecenter/ssw_ibm_i_74/rzahz/rzahzpdf.pdf?view=kc |access-date=2020-09-05 |url-status=live|archive-url=https://web.archive.org/web/20200918130823/https://www.ibm.com/support/knowledgecenter/ssw_ibm_i_74/rzahz/rzahzpdf.pdf?view=kc |archive-date=2020-09-18 }}</ref>

The version of <code>chgrp</code> bundled in GNU coreutils was written by David MacKenzie.<ref>{{man|1|chgrp|Linux}}</ref>

==Use==

Generally, the syntax can be described as:

chgrp [''options''] ''group'' ''files''

* ''group'' specifies the group with which the files should be associated; may be either a symbolic name or an identifier * ''files'' specifies one or more files, which may be the result of a glob expression like {{code|*.conf}}

Options: * {{code|-R}} '''R'''ecurse through directories * {{code|-v}} '''V'''erbose output: log the name of each file changed * {{code|-f}} '''F'''orce or '''f'''orge ahead even if an error occurs

==Examples== The following demonstrates changing the group of files matching {{code|*.conf}} to ''staff'' {{endash}} provided the user owns the files (is ''gbeeker'') and is a member of ''staff''. The change will allow members of the group ''staff'' to modify the files since the group-class permissions (read/write) will apply, not the others-class permissions (read only).

<syntaxhighlight lang="console" highlight="4"> $ ls -l *.conf -rw-rw-r-- 1 gbeeker wheel 3545 Nov 04 2011 prog.conf -rw-rw-r-- 1 gbeeker wheel 3545 Nov 04 2011 prox.conf $ chgrp staff *.conf $ ls -l *.conf -rw-rw-r-- 1 gbeeker staff 3545 Nov 04 2011 prog.conf -rw-rw-r-- 1 gbeeker staff 3545 Nov 04 2011 prox.conf </syntaxhighlight>

==See also== * {{Annotated link|chmod}} * {{Annotated link|chown}} * {{Annotated link|Group identifier (Unix)}} * {{Annotated link|List of POSIX commands}}

==References== {{Reflist}}

==External links== {{Wikibooks|Guide to Unix|Commands}} * {{man|cu|chgrp|SUS|change the file group ownership}} * {{man|1|chgrp|Plan 9}} * {{man|1|chgrp|Inferno}}

{{Unix commands}} {{Plan 9 commands}} {{Core Utilities commands}}

Category:Operating system security Category:Standard Unix programs Category:Unix SUS2008 utilities Category:Plan 9 commands Category:Inferno (operating system) commands Category:IBM i Qshell commands

de:Unix-Kommandos#Benutzer- und Rechteverwaltung