To add a user to a team, open up the Terminal, then style “sudo usermod -a -G examplegroup exampleusername” into the window. Substitute “examplegroup” and “exampleusername” with the team and username you want to modify.
Changing the group a consumer is connected to is a reasonably simple activity, but not all people appreciates the instructions, especially to add a consumer to a secondary group. We’ll walk by means of all the eventualities for you.
Consumer accounts can be assigned to a single or more teams on Linux. You can configure file permissions and other privileges by team. For instance, on Ubuntu, only customers in the sudo group can use the
sudo command to obtain elevated permissions.
If you are working with a new Linux notebook, you may possibly have some form of GUI interface to configure these options (dependent on the distribution that you are jogging, at the very least) but realistically it’s virtually usually less difficult to just fall down to the terminal and sort out a number of commands, so that’s what we’re showing you right now.
Add a New Team
Related: What is actually the Change Concerning Sudo and Su in Linux?
If you want to create a new group on your procedure, use the
groupadd command following command, replacing new_group with the title of the group you want to develop. You will need to have to use sudo with this command as well (or, on Linux distributions that really don’t use
sudo, you’ll need to have to run the
su command on its have to get elevated permissions ahead of functioning the command).
sudo groupadd mynewgroup
Include an Current Person Account to a Team
To include an current consumer account to a team on your program, use the
usermod command, changing
examplegroup with the name of the group you want to insert the consumer to and
exampleusername with the title of the person you want to include.
usermod -a -G examplegroup exampleusername
For example, to increase the consumer
geek to the group
sudo , use the next command:
usermod -a -G sudo geek
Change a User’s Key Group
When a person account can be element of a number of teams, just one of the teams is generally the “primary group” and the many others are “secondary groups”. The user’s login approach and documents and folders the person makes will be assigned to the most important team.
To alter the key group a user is assigned to, run the
usermod command, changing
examplegroup with the name of the group you want to be the primary and
exampleusernamewith the identify of the person account.
usermod -g groupname username
-g listed here. When you use a lowercase g, you assign a primary team. When you use an uppercase
-G , as over, you assign a new secondary team.
Connected: How to Handle sudo Access on Linux
Watch the Teams a Consumer Account is Assigned To
To look at the groups the present person account is assigned to, run the
teams command. You will see a list of groups.
To look at the numerical IDs connected with each team, operate the
id command alternatively:
To watch the teams a different consumer account is assigned to, operate the
teams command and specify the identify of the user account.
You can also perspective the numerical IDs related with just about every group by operating the
id command and specifying a username.
The very first group in the
teams record or the team proven soon after “gid=” in the
id listing is the person account’s principal group. The other teams are the secondary groups. So, in the screenshot under, the person account’s main group is
case in point.
Generate a New User and Assign a Group in A single Command
You might at times want to build a new consumer account that has entry to a particular useful resource or directory, like a new FTP person. You can specify the teams a person account will be assigned to when building the person account with the
useradd command, like so:
useradd -G examplegroup exampleusername
For instance, to build a new consumer account named jsmith and assign that account to the ftp team, you’d run:
useradd -G ftp jsmith
You will want to assign a password for that person later on, of class:
Associated: How to Use the FTP Command on Linux
Incorporate a Person to Numerous Teams
While assigning the secondary teams to a person account, you can easily assign multiple groups at once by separating the list with a comma.
usermod -a -G team1,team2,group3 exampleusername
For example, to include the user named geek to the ftp, sudo, and instance teams, you’d run:
usermod -a -G ftp,sudo,instance geek
You can specify as numerous teams as you like—just different them all with a comma.
Linked: The Most effective Linux Distributions for Novices
Perspective All Teams on the Technique
If you want to perspective a list of all groups on your program, you can use the
This output will also show you which user accounts are associates of which groups. So, in the screenshot under, we can see that the user accounts syslog and chris are associates of the adm team.
That should protect every little thing you will need to know about adding customers to teams on Linux.
Related: The Finest Linux Laptops of 2022