.. index:: group, file ownership .. _groups1: Understanding Ownership and Group Ownership -------------------------------------------- :t:`Linux for Programmers and Users`, Sections 3.27, 3.28, 3.29 We have seen from the output of :option:`ls -l` (see :ref:`ls`), that each file has an owner and a group owner. .. note:: A :dfn:`group` is a collection of users that can potentially share files with each other that are not shared with everyone. Groups are usually defined in the :file:`/etc/group` file. File permissions are grouped by three classes of users: #. Owner of the file #. Group Owners #. Others In the output of :option:`ls -l`, the middle set of permissions for **r**\ ead, **w**\ rite and e\ **x**\ ecute are group permissions. Entry for romeo in :file:`/etc/passwd`:: romeo:x:1003:1003::/home/romeo:/usr/bin/ksh Entry for romeo's group (1003) in /etc/group:: romeo::1003: Here romeo is in a group by himself. This is a common practice, as it keeps files with liberal group permission from being shared with others unintentionally. Our user romeo may also be in other groups so that select files and directories may shared with colleagues. .. _groups: groups ^^^^^^^ .. index:: groups .. program:: groups .. describe:: groups Lists names of groups that the user is in. SYNOPSIS :command:`groups` [USERNAME]... :: $ groups romeo tailgaters shakespeare $ getent group shakespeare shakespeare:x:3023:romeo,juliet .. note:: How does :option:`ls -l` print the name of the owner and group owner? If a file `foo` is owned by `romeo` and group owned by `users`, the inode for foo stores 1003 and 101 as the UID and GID, respectively. :command:`ls` first looks up the inode for these two parameters and then translates them to their name representation using `/etc/passwd` and `/etc/group`. Why doesn't romeo's name appear in the entry in /etc/group?