Adding, managing and deleting groups on Linux

$ sudo groupadd -g 1111 techs

In this case, a specific group ID (1111) is being assigned. Omit the -g option to use the next available group ID (e.g., sudo groupadd techs). Once a group is added, you will find it in the /etc/group file.

$ grep techs /etc/group
techs:x:1111:

Adding or removing users from groups

To add a member to a secondary group file, use a command like this that adds jdeo to the techs group:

$ sudo usermod -aG techs jdoe

Check the /etc/group file for the addition with a command like this:

$ grep techs /etc/group
techs:x:1111:shs,jdoe

To remove a user from a group, use a command like this where the -a (add) is replaced with the -r options:

$ sudo usermod -rG techs jdoe

Removing a group

To remove a group, use the groupdel command as in the example below.

$ sudo groupdel techs

Wrap-up

Setting up and managing groups on Linux systems can help when you need to assign specific privileges to particular groups of people.



Source link

Leave a Comment