Group Management
In this lesson, we will explore how to manage groups on a Linux/Unix system. This involves creating groups, adding and removing users from groups, and deleting groups. Additionally, we will delve into the structure of the /etc/group and /etc/gshadow files.
Creating a Group
groupadd (Create New Group) Let's start by creating a new group named developers:
sudo groupadd developers # Creates a new group
The /etc/group File
Each line in the /etc/group file represents a single group on the system and is divided into four fields separated by colons (:). The format is as follows:
groupName:password:groupID:userList
groupName:- This field specifies the name of the group. It is the identifier used when assigning group permissions or adding users to groups.
password:- This field traditionally held the encrypted password for the group. However, in modern systems, this field is usually set to
x, indicating that the actual encrypted password is stored in the/etc/gshadowfile for enhanced security.
- This field traditionally held the encrypted password for the group. However, in modern systems, this field is usually set to
groupID(GID):- This field holds the unique numeric ID assigned to the group. This Group ID (GID) is used by the system to manage group permissions and memberships.
userList:- This field contains a comma-separated list of usernames who are members of the group. If a user is added to a group, their username will appear in this list. Othewise this will remain empty.
Let's search the /etc/group file for our developers group:
grep "developers" /etc/group
And the output of that command:
developers:x:1003:
In this example:
developers:- This is the name of the group. In this case, the group is called "developers."
x:- This entry in the password field indicates that the actual encrypted password for the group is stored in the
/etc/gshadowfile for bette…
- This entry in the password field indicates that the actual encrypted password for the group is stored in the
No comments yet. Add the first comment to start the discussion.