Add and delete users in the group easily on Ubuntu
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
- Which groups are used for Linux?
- Add users to the group in Ubuntu
- Create a new group in Ubuntu
- Delete the user from the group in Ubuntu
- 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.
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
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.
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.
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
Provide Yes for the prompt, then wait for the download and installation packages. After installation is complete, launch the Users and Groups application .
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.
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.
You should read it
- How to easily add and delete users on Ubuntu
- What's New in Ubuntu 21.10?
- How to Edit Ubuntu Repositories
- Why is Ubuntu LTS preferred over regular distros?
- What's new in Ubuntu 18.04 LTS just released?
- How to prolong the life of Ubuntu 18.04 installation with Ubuntu Pro
- How to assign admin rights to users in Ubuntu
- What is the difference between Ubuntu Desktop and Ubuntu Server?
- Ubuntu 21.04 users need to update the system ASAP
- 5 things to do after upgrading to Ubuntu 22.04 LTS
- 5 Reasons Ubuntu Cinnamon Is Better Than Other Ubuntu Versions
- 10 reasons to choose Ubuntu 12.10 instead of Windows 8
Maybe you are interested
Instructions to enable tab groups in Firefox
Instructions to turn off tab group icons on Chrome
How to block adding friends to strange WhatsApp groups
What to do if you can't leave a group conversation on iPhone?
Instructions for creating Instagram group chat - Group chat stickers on Story
Guide to group voice and video calls on WhatsApp