How to create and manage user groups in Ubuntu?

In Ubuntu, you can use the following commands to create and manage user groups:

  1. Create a user group.
sudo groupadd groupname

The groupname is the name of the user group that needs to be created.

  1. Add users to a user group.
sudo usermod -a -G groupname username

“Where ‘groupname’ is the name of the user group, and ‘username’ is the username to be added to the user group.”

  1. View user group information.
cat /etc/group

This will list all user groups and their members.

  1. Remove user group.
sudo groupdel groupname

In this case, groupname refers to the name of the user group that needs to be deleted.

  1. Change the name of the user group:
sudo groupmod -n newname oldname

newname is the new name to be changed to, while oldname is the old name to be changed.

With the above commands, you can create and manage user groups in Ubuntu.

bannerAds