0% found this document useful (0 votes)
7 views7 pages

Group Management

The document outlines the management of user groups in a system, emphasizing the importance of the /etc/group file for sysadmins. It details commands for creating, modifying, and deleting groups, as well as adding and removing users from groups using gpasswd and groupadd/groupmod/groupdel commands. Understanding these processes is crucial for efficient user account management and resource access control.

Uploaded by

suzukikun583
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views7 pages

Group Management

The document outlines the management of user groups in a system, emphasizing the importance of the /etc/group file for sysadmins. It details commands for creating, modifying, and deleting groups, as well as adding and removing users from groups using gpasswd and groupadd/groupmod/groupdel commands. Understanding these processes is crucial for efficient user account management and resource access control.

Uploaded by

suzukikun583
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Group Mnagement

Managing groups
It's more efficient to group user accounts with similar access requirements than to
manage permissions on a user-by-user basis. Therefore, sysadmins need to be
comfortable with the process of creating, modifying, and deleting groups.
1. Understand the /etc/group file
Similar to the /etc/passwd file above, the /etc/group file contains group account
information. This information can be essential for troubleshooting, security audits,
and ensuring users can access the resources they need.
Understand each field of the file to make life easier as a sysadmin.
The fields in the /etc/group file are:
groupname:password:GID:group members
Here is an example of the editors group with two members:
editors:x:2002:damon,tyler
2. Create, modify, and delete groups
Like the user account commands described above, the group management
commands are very intuitive and provide a lot of flexibility. There is an easy-to-
remember command for each function you might need to carry out for a group:
•groupadd
•groupmod
•groupdel
8. Add User to Group
To add a user to a group, we can use gpasswd -a:
$ id new_user
uid=2027(new_user) gid=2027(new_user) groups=2027(new_user)
$ sudo gpasswd -a new_user baeldung
Adding user new_user to group baeldung
$ id new_user
uid=2027(new_user) gid=2027(new_user)
groups=2027(new_user),1000(baeldung)
The command has appended the specified group to new_user‘s groups.
9. Remove User From Group
We can use gpasswd -d to remove a user from a group:
$ id new_user
uid=2027(new_user) gid=2027(new_user)
groups=2027(new_user),1000(baeldung)
$ sudo gpasswd -d new_user baeldung
Removing user new_user from group baeldung
$ id new_user
uid=2027(new_user) gid=2027(new_user)
groups=2027(new_user)
The command has removed new_user from the specified
group.
10. Create a New Group
We can use groupadd to create a new group:
$ sudo groupadd new_group
$ cat /etc/group | grep new_group
new_group:x:2028:
The command has created a new group, and its group ID is 2028.

11. Modify Group


We can use groupmod to modify a group.
11.1. Change GID
We can add the -g option to change the group ID of an existing group:
$ cat /etc/group | grep new_group
new_group:x:2028:
$ sudo groupmod -g 2040 new_group
$ cat /etc/group | grep new_group
new_group:x:2040:
The command has changed the group ID from 2028 to 2040.
11.2. Change Group Name
To change a group’s name, we can add the -n option:
$ cat /etc/group | grep new_group
new_group:x:2040:
$ sudo groupmod -n new_name new_group
$ cat /etc/group | grep new_name
new_name:x:2040:
The command has changed the group’s name
from new_group to new_name.
12. Delete a Group
To remove an existing group, we can use groupdel:
$ sudo groupdel new_groupCopy

You might also like