Linux 101 : Linux groups

Linux Groups helps us group together users with the same access and security requirements.

Instead of individually giving the same access rights to different users , we put them in the same group and give the groups those permissions.
A group is identified by its GID or Group ID, users can be member or one or more groups.

To have a look at the existing group, we could check the "/etc/group" file.
The groups are made up of the below fields:


The sign "x" in the password field means that the password is encrypted and safely stored in the "/etc/gshadow" file that can't be accessed by regular users.

To create a group, we use the command "groupadd", for example:

  • -g : allows us to give a group a group ID.
  • -f : if the group already exists the command exits with success.
To assign a group to a file or directory, we could use the below command:

To add a group permission for a file, we use the below command:

To remove a group permission for a file, we use the below command:

"X" could be "r" for read rights, "w" for write rights or "x" for execution rights for files or browsing rights for directories.
It could also be any combination of "read", "write" and "execute" rights.

We could also use the below command to modify a group's parameters:

  • -g : Change the group's ID. 
We could also use that command to change a group's name as below:

  • -n : Rename a group. 
To delete a group, we use the below command. It does not delete the members of the groups, but they would lose the access privilege they had through the group they belonged to:

To see the access privileges enjoyed by a group, we use the below command:

We could see that the "root" group has "read" rights on the file "history.txt"


Leave as a comment: