1. Technology
You can opt-out at any time. Please refer to our privacy policy for contact information.

Discuss in my forum

Example uses of the command "groups"

A Brief Introduction


The groups command prints out the list of groups that you or another user belong to. A group is a set of users. Groups are generally used to provide special access to directories and files which only members of that group have a need to access.

If you type in

at the command line without any arguments, you will get a list of the groups that your login id (user name) is a member of. The first group in this list is the default group, which will be the group that new files and directories you are creating are associated with for access permission purposes.

With the list command:

ls -l
you can see the permission settings, including the group, for the files and directories in the current directory.

You can change the default group with the sg command.

If you enter a user name as argument to groups it will list the groups that the specified user is a member of. For example,

groups bwillis
will list bwillis' groups.
  1. About.com
  2. Technology
  3. Linux
  4. Linux / Shell Commands
  5. Example uses of the Linux Command "groups"

©2014 About.com. All rights reserved.