Even as a relatively experienced Linux user, you may not often think about groups. In many cases, basic groups are formed when you create a new user during system setup.

However, when administering your system, you may encounter a situation where you need to add users to a group. It's easy to add or remove users from a group on Ubuntu. If you don't know how to do it, follow the following article.

How to add and delete users in Linux Ubuntu

  1. Which groups are used for Linux?
  2. Add users to the group in Ubuntu
  3. Create a new group in Ubuntu
  4. Delete the user from the group in Ubuntu
  5. An easier way to add and delete users from the group

Which groups are used for Linux?

Groups in Linux are exactly a collection of users. They are used to manage permissions on some users instead of modifying them on a per user basis. It is important to understand this concept because it is used across all Unix-like operating systems, not just Linux.

A user needs to belong to at least one group. This is the main group of that user. A user can and usually belongs to other groups, called secondary groups. There is usually a limit to the number of groups the user can be in.

Of course, groups are not the only way to handle rights in Linux. To handle permissions on a per-user basis, see the TipsMake.com instructions for decentralizing file access with the chmod command.

Add users to the group in Ubuntu

There are two commands you should know when you want to add users to a group on Linux. These are commands groups and usermod commands. The groups command allows you to see which groups you have specified. Simply run the following command:

 groups 

Before adding users to a group, you should make sure that the user actually exists. To do this, you can use the getent command. To list all groups, run the following command:

 getent group 

You will see a list of groups, as well as which users are assigned to them.

Add and delete users in the group easily on Ubuntu Picture 1

To add users to a group, use the usermod command. Usually, you do this with a command like this:

 sudo usermod -a -G group username 

With the above command, replace the group with the name of the group you want to add users and replace the username with the user's name. For example:

 sudo usermod -a -G sudo kwouksudo usermod -a -G sudo kwouk 

This will allow kwouk users to use the sudo command . Because only users in that group can use sudo, you can only run the usermod command if you already have that group.

Although this tutorial focuses on Ubuntu, to add users to a group on other distributions, you can apply the same steps.

Create a new group in Ubuntu

Sometimes, you will encounter a situation where you need to add a user to a group, but that group does not exist. In this case, you will need to manually create the group, this is at the groupadd command to promote the role.

This command is very easy to use. Simply run it under sudo with the name of the group you want to create. For example:

 sudo groupadd newgroup 

Add and delete users in the group easily on Ubuntu Picture 2

The above command will create a group called 'newgroup'. It may be very rare for you to run this command, but installing certain software may require you to create new groups. To add a user to a group you just created, use the same steps outlined above.

Add and delete users in the group easily on Ubuntu Picture 3

Delete the user from the group in Ubuntu

Now, you know how to add users to a group on Linux, but what about deleting them from a group? This may be different on Linux distributions, but fortunately, removing users from a group on Ubuntu is easy.

The deluser command, as its name implies, is often used to completely delete a user. You can also use it on Ubuntu to delete users from a group, as well as on other distributions like Debian, where this package is also available. To remove a user from a group, use the following command:

 sudo deluser username groupname 

Always make sure to check if the group name is available. If you run the command without a group name, the command will only delete that user completely. For example, the following command will delete the user from the sudo group.

 sudo deluser kwouk sudo 

If you omit the last part 'sudo' in the above command, the user named 'kwouk' will be deleted completely.

Add and delete users in the group easily on Ubuntu Picture 4

It's best to check the groups that the user has been assigned. To do this, simply run the following command:

 sudo groups username 

An easier way to add and delete users from the group

Many people like to use a graphical tool on Ubuntu to add users and delete them from groups. If you often need to do this and don't like working on the command line, the following method can make your work much easier. Fortunately, this method is not only feasible but also easy to implement.

To do this, you will need to install the 'gnome-system-tools' package , which contains several different utilities.

We only care about the 'Users and Groups' application , but still need to install the entire package. To do this, run the following command:

 sudo apt install gnome-system-tools 

Add and delete users in the group easily on Ubuntu Picture 5

Provide Yes for the prompt, then wait for the download and installation packages. After installation is complete, launch the Users and Groups application .

Add and delete users in the group easily on Ubuntu Picture 6

On the left side, you will see a list of users on the system. To add and remove users from the group, click Manage Groups . You will see a list of all available groups in your Ubuntu installation. Add users to the group by clicking on Properties and checking the box next to their name. Delete users from groups by unchecking the corresponding box.

Add and delete users in the group easily on Ubuntu Picture 7

The origin of Unix dates back to the 1970s and Linux continues to grow today. This does not just mean better hardware support and performance. As Linux grows, we have seen more ways to manage users and permissions.

Ubuntu 19.10 brings the version of Gnome 3.32, with additional application control. This allows you to use smartphone application permissions. Although this feature is still in its infancy, it eventually made the Linux desktop more secure. To explore other new things, see TipsMake.com 's guide to upcoming new features in Ubuntu 19.10.

5 ★ | 1 Vote | 👨 288 Views

Above is an article about: "Add and delete users in the group easily on Ubuntu". Hope this article is useful to you. Don't forget to rate the article, like and share this article with your friends and relatives. Good luck!

« PREV POST
NEXT POST »