Create, delete and modify local groups and group memberships

Create a group :

# groupadd profesores

Create group with GID :

# groupadd administrativos -g 5000

See existing groups :

# cat /etc/group
...
charles:x:1003:
profesores:x:1004:
administrativos:x:5000:

Change the group name:

# groupmod -n teachers profesores 

We check with--> # tail -1 /etc/group
teachers:x:1004:

Delete a group :

# groupdel administrativos

Modify the group to a user :

# usermod -G teachers usuario10 
(Here I'm removing usuario10 from his older group and adding to teachers group.)

See who is part of the group :

# groupmems -g teachers -l
usuario10

or:
# getent group servicios

Add / Remove a user from a group:

Add a user from a group:
# gpasswd -a usuario10 teachers
(Adding user usuario10 to group teachers)

Remove a user from a group:
# gpasswd -d usuario10 teachers
( Removing user usuario10 from group teacher)

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *