Skip to content

Viewing User Group Information

Kristina edited this page Jan 3, 2018 · 1 revision

Every user is assigned an unique user ID (uid) in Linux.

Linux uses groups for organizing users and handling permissions. Each group has a unique ID (gid) assigned to it and each users is assigned to a default group which has the same id number as the users.

Groups membership is controlled by the /etc/group file which has a list of groups and it’s members.

To view the information in the /etc/group file simply type less /etc/group. When you run the less /etc/group command you should see something like the screen shot below.

Less group command

Each line in the file is for a different group. The format of each line is Group Name:Password:GroupID (GID):User list. For example the adm:x:4:syslog,kristina line means:

  • Group name = adm
  • Password = no password (x means no password)
  • Group ID (GID) = 4
  • Users in the group = syslog and kristina

Most groups don’t have a password as you can see from the screen shot above.

To view what groups a user is a part of you can use the following commands:

1.groups (username)

Kristina's groups

2.groups (shows groups that the current user is assigned to)

Groups commands

3.id -g (this command will get the current user’s unique group id)

Current user's group

4.id -g (username) (this command will get the user’s unique group id)

Another user's groups

5.id -G (this command will list all the group ids (GID) that the current user is a member of)

Current user's group ids

6.id -G (username) (this command will list all the groups ids (GID) that the user is a member of)

Another user's group ids

Clone this wiki locally