Group Identifier (gid) in Linux [A Complete Overview]

Group Identifier or gid in Linux is a term often used to identify groups and their permissions. The gid indicates the group number inside a Linux system. This group system often provides or limits system resources and permission. In this article, I will discuss all the features and aspects of the gid in Linux.

What is gid in Linux?

The group identifier or gid in Linux is helpful to identify the system and limit what that group can access. There is a numbering system that allows finding information about a group easily.

  • gid 0 (zero) means root group. This number is reserved for the root in the Linux
  • gid 1-99 are allocated for the system and application
  • gid 100+ (more than 100) is for the user’s group. The users in the system create these groups.

groups with gid in linux

Creating a Group

You can create groups in different ways. Sometimes you may want to create groups by serial number. But you may also want to keep gid according to your need. Here are 2 different methods of creating groups.

Method 1: Creating Groups by the Default Serial Number

Creating a group is very easy. But you will find your gid in serial. You can access the gid about the groups from the end of the /etc/group file. Here, as you can see, I created a group called LinuxSimply and by default, the gid is 1004 by serial.

sudo groupadd LinuxSimply
cat /etc/group | tail -5

Output >

You’ll have to enter your password. In the command line, you’ll find the group name and gid.

adding a group and showing the gid in linux

Method 2: Creating Groups by gid in Linux

But to create a group with a specific gid, you need to use the -g option.

sudo groupadd -g 3333 LS
cat /etc/group | tail -5

Output >

As you can see, at the end of the group file, there are all the groups.

showing the last 5 groups and gid in linux

Displaying Group Names and gid in Linux

Using different methods, you can display the groups’ names in the command line. Here are 4 different methods to view groups and gid according to need.

Method 1: Showing the gid of the User’s Group

You can show the gid of the current user’s group using any of the commands below.



id -g USER

Output >

In the command line, you will see the gids of the User group.

showing group information for a user

Method 2: Finding All the Groups with gid Available to the User

You may want to find all the groups gid available to the user using the -G option. It will only show the gid, not the groups name. To find the groups’ names, you need to access the /etc/group file.

id -G USER

Output >

You will find all the gids available to the user in the command line.

creating a group with custom gid

Method 3: Finding All the Groups with gid

You can also show all the groups with their gid available in the Linux system. To do that you need to access the group file in the etc folder. But the group file also contains all the names of the system groups. So the whole command line will get filled up. So piping the tail command or less command is recommended.

cat /etc/group | tail -5


cat /etc/group | less

Output >

As you can see, the command line the last created groups are shown with their gids.

Showing all gid available to a user

Method 4: Finding all the Groups Names with gid of a User

Sometimes, you know a user name, but don’t know about the group names and gids available to the user. You can find it by piping the group file with the grep command.

cat etc/group | grep USER

Output >

Here, you will see the grep command finding the line with softeko and showing the gid.

showing all groups and gids with grep command


Here, you’ve learned about some of the use of gid and how to find them using the command line. These commands will come in handy when you start using multiple groups and permissions. For professionals and server users, these commands will be a daily driver to find and look at the gids of different groups.

Similar Readings

Rate this post
Md. Rafsan Zani

Hello, I’m Md. Rafsan Zani. I have recently completed my Undergraduate from the Bangladesh University of Engineering and Technology (BUET). Currently, I’m pursuing higher studies abroad. I’m really interested in computer science and would like to learn a lot about the wonderful world of computers. Currently, I’m working as a Linux Content Developer Executive and find Linux really interesting. I certainly would like to learn more about Linux and implement them in my future studies. Read Full Bio

Leave a Comment