# Chgrp

> Mediated Wiki article. Canonical URL: https://mediated.wiki/source/Chgrp
> Markdown URL: https://mediated.wiki/source/Chgrp.md
> Source: https://en.wikipedia.org/wiki/Chgrp
> Source revision: 1328452774
> License: Creative Commons Attribution-ShareAlike 4.0 International (https://creativecommons.org/licenses/by-sa/4.0/)

{{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](/source/AT%26T_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](/source/C_(programming_language))
| operating system       = [Unix](/source/Unix), [Unix-like](/source/Unix-like), [Plan 9](/source/Plan_9_from_Bell_Labs), [Inferno](/source/Inferno_(operating_system)), [IBM i](/source/IBM_i)
| platform               = [Cross-platform](/source/Cross-platform)
| size                   = 
| language               = 
| language count         = <!-- Number only -->
| language footnote      = 
| genre                  = [Command](/source/Command_(computing))
| license                = Plan 9: [MIT License](/source/MIT_License)
| alexa                  = 
| website                = <!-- {{URL|example.org}} -->
| standard               = 
| AsOf                   = 
}}

'''{{code|chgrp}}''', short for '''ch'''ange '''gr'''ou'''p''', is a [shell](/source/shell_(computing)) [command](/source/command_(computing)) for changing the [group](/source/group_(computing)) associated with a [Unix](/source/Unix)-based [file system](/source/file_system) [file](/source/computer_file) {{endash}} including special files such as [directories](/source/directory_(computing)). 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](/source/file-system_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](/source/Unix) operating system by [AT&T Bell Laboratories](/source/AT%26T_Bell_Laboratories). It is available in most [Unix-like](/source/Unix-like) systems, [Plan 9](/source/Plan_9_from_Bell_Labs), [Inferno](/source/Inferno_(operating_system)) and [IBM i](/source/IBM_i).<ref>{{cite web |title=IBM System i Version 7.2 Programming Qshell |language=en |author=IBM |website=[IBM](/source/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](/source/GNU) [coreutils](/source/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](/source/Group_identifier_(Unix))
* ''files'' specifies one or more files, which may be the result of a [glob](/source/glob_(programming)) 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](/source/de%3AUnix-Kommandos)

---
Adapted from the Wikipedia article [Chgrp](https://en.wikipedia.org/wiki/Chgrp) by Wikipedia contributors ([contributor history](https://en.wikipedia.org/wiki/Chgrp?action=history)). Available under [Creative Commons Attribution-ShareAlike 4.0 International](https://creativecommons.org/licenses/by-sa/4.0/). Changes may have been made.
