chgrp

From Wikipedia, the free encyclopedia
Jump to navigation Jump to search
chgrp
DeveloperAT&T Bell Laboratories
Initial releaseMay 1975; 51 years ago (1975-05)
Repository
  • {{URL|example.com|optional display text}}Lua error in Module:EditAtWikidata at line 29: attempt to index field 'wikibase' (a nil value).
Written inPlan 9: C
Engine
    Lua error in Module:EditAtWikidata at line 29: attempt to index field 'wikibase' (a nil value).
    Operating systemUnix, Unix-like, Plan 9, Inferno, IBM i
    PlatformCross-platform
    TypeCommand
    LicensePlan 9: MIT License

    chgrp, short for change group, is a shell command for changing the group associated with a Unix-based file system file – including special files such as directories. Changing the group of a file is restricted to a super-user (such as via 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

    [edit | edit source]

    The 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.[1]

    The version of chgrp bundled in GNU coreutils was written by David MacKenzie.[2]

    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 *.conf

    Options:

    • -R Recurse through directories
    • -v Verbose output: log the name of each file changed
    • -f Force or forge ahead even if an error occurs

    Examples

    [edit | edit source]

    The following demonstrates changing the group of files matching *.conf to staff – 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).

    $ 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
    

    See also

    [edit | edit source]
    • chmod – Shell command for changing access permissions of a file
    • chown – Shell command for changing the owner of a file
    • Group identifier (Unix) – Unix/POSIX system account group number; numeric value used to represent a specific group
    • List of POSIX commands

    References

    [edit | edit source]
    1. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    2. ^ chgrp(1) – Linux User Manual – User Commands from Manned.org
    [edit | edit source]

    de:Unix-Kommandos#Benutzer- und Rechteverwaltung