Adding a user to a group is a fairly simple task. It is not that difficult like coding an entire program in the prompt. But, most of the beginners are unaware of the commands and steps to do so. So, in this article on “Linux Add User to Group,” we are going to list the complete step by step procedure. Have a look at a detailed guide below.
Add a New Group to Linux
Before starting, it is necessary to add a group to the Linux if you don’t already have one. You can do that by typing this code in the terminal.
Linux Add User to Group
To add a user to an existing group, use the following commands.
usermod -a -G <groupname> username
Replace the groupname and username with the correct names of the group and user.
Change User’s Group
If the user and group already exist and you want to switch the user to a different group, use the following command.
usermod -g <groupname> username
Replace the appropriate names as you done before.
Add a User to Multiple Groups at the same time
There are instances where you want to add the same user to multiple groups. To do this, use the following command in the terminal.
usermod -a -G ftp,admins,secondgroup <username>
Here, we just added a comma in between the user groups. Replace the user groups with the correct names.
That’s all that you have to do to create and manage users and groups in Linux. If you faced any problems in the process or need help regarding it, feel free to ask through the comments.
That’s all for now. Hope you liked the article, please don’t forget to share on your social media platforms. Also, please do share your views and feedback in the comment box below.