Working with Groups
groups | Print the group membership of a user |
groupadd | Create a new group |
groupdel | Delete a group |
groupmod | Modify a group |
A group is a set of user accounts treated as a single entity. If you give permission for a group to take some action (such as modify a file), then all members of that group can take it. For example, you can give full permissions for the group friends
to read, write, and execute the file /tmp/sample:
$ groups users smith friends $ chgrp friends /tmp/sample $ chmod 770 /tmp/sample $ ls -l /tmp/sample -rwxrwx--- 1 smith friends 2874 Oct 20 22:35 /tmp/sample
To add users to a group, edit /etc/group as root.[16] To change the group ownership of a file, recall the chgrp
commands from File Properties.
[16] Different systems may store the group member list in other ways.
Get Linux Pocket Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.