Introduction
In Unix-like operating systems, permission management is based on the combination of users and groups. Each process, file, or device has an associated owner (user) and group that determines who can read, write, or execute. Knowing which groups a user belongs to is the first step for diagnosing access problems, adjusting privileges, and maintaining system security.
What exactly does the groups command do?
The groups command belongs to the GNU coreutils basic utilities set. Its function is to print to standard output the list of groups to which a specified user belongs, or, if no name is given, the user executing the command. The output consists of group names separated by spaces, making it easy to process with tools such as awk, sed, or cut.
Syntax and options
The simplest form is:
groups [user]
There are no long or short options that modify its behavior; the command ignores any additional argument beyond the username. If more than one name is provided, it will display the list for each on separate lines.
Everyday usage examples
- View the groups of the current user:
groups
juan:groups juan
groups juan | tr ' ' ','This post is also available in ESPAÑOL.