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.
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 what 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.