• Home
  • Windows
    • Windows 10
    • Windows 11
  • Mac
  • iOS
  • iPad
  • iPhone
  • Social Media
  • News
Thursday, June 8, 2023
HowToFixIssue
  • Home
  • Windows
    • Windows 10
    • Windows 11
  • Mac
  • iOS
  • iPad
  • iPhone
  • Social Media
  • News
No Result
View All Result
  • Home
  • Windows
    • Windows 10
    • Windows 11
  • Mac
  • iOS
  • iPad
  • iPhone
  • Social Media
  • News
No Result
View All Result
HowToFixIssue
No Result
View All Result
Home How To

How to Add a User to a Group in Linux (2023 Guide)

March 12, 2023
in How To
Reading Time: 9 mins read

InterestingPosts

How to Find the Sniffer Egg in Minecraft (2023)

Decky Loader on Steam Deck: How to Install Best Plugins

Diablo 4: How to Leave Dungeons (3 Ways)

How to Add a User to a Group in Linux (2023 Guide).

Assume you’re a system administrator of a giant challenge, and also you typically obtain complaints from the QA crew that the event crew is messing up the codebase and vice versa. Upon shut inspection, you discover out that two teams are part of the identical group, sharing the identical codebase. So you ask your senior to assist with the issue, and he advises you to make two teams for all of the customers of the event and QA teams. But, you don’t have any clue how so as to add customers to a gaggle in Linux. Well, we’re right here to assist remedy this drawback. In this text, now we have defined how to create a brand new group, create new customers, after which add a person to a gaggle in Linux.

Adding Users to a Group in Linux (2023)

Before we exhibit how to create teams, create customers, and add new or current customers to those teams, we first have to study what’s a person group in Linux. So let’s have a look at what are person teams after which transfer on to including customers to a gaggle.

What is a User Group in Linux

Generally, a company is split into teams, with every crew having a unique operate and each member of the group is a part of a crew. Similarly, in a multi-user system, each person is a part of a gaggle having a unique set of privileges like studying, writing, or executing permissions for a shared useful resource inside the group. There are two varieties of teams in Linux:

Primary Group

Whenever you log in to a session, you might be a part of the first group. Generally, the first group bears the identical title because the username in Linux. Any file or course of created by you is a part of this group and can’t be accessed by customers of different teams by default. Information reminiscent of person id, group id, and many others. a couple of main group is saved within the file – /and many others/passwd.

Secondary Group

Secondary teams or supplementary teams are helpful when that you must share entry to any information or processes with a specific group of customers. Only the basis person or customers with sudo privileges can assign new permissions or add new customers to the secondary teams.

A person can solely be a part of one main group however might be a part of a number of secondary teams. Now that you realize the fundamentals of person teams in Linux, allow us to now see how to create new customers and add them to a gaggle.

How to Add New Users in Linux

To create new customers, use the useradd command as per the next syntax:

sudo useradd <choices> username

Some of the choices to pair up with the command are:

Options Description
-d The new person might be created using a brand new listing title as the worth for the person’s login listing
-e This is used to specify the date on which the person account will get deactivated
-u This will create a brand new person with a selected user-id
creating new user with useradd command

The new person you create will solely be part of the first group initially. Once you create a brand new person, assign them a brand new password using the passwd command, as proven under:

sudo passwd <username>

Here, you’ll be prompted to enter the brand new password after which requested to re-enter the password for affirmation. At this level, the person can now log in to the system with the brand new username and password you simply created.

creating new password for the new user

How to Create a User Group in Linux

Now that you’ve created a brand new person, you can begin creating teams and including customers to them. To create a brand new group, use the groupadd command. Be positive to present a novel title to the brand new group title, or it is going to conflict with different current group names. Here’s what the syntax appears like:

sudo groupadd <group_name>

creating new group

How to Add Users to Groups

Once you might have created a gaggle, now you can begin including customers to it. Only a root person or a person with sudo entry can add customers to completely different teams.

Add Existing User to An Existing Group

To add an current person to a gaggle, use the usermod command whose syntax now we have highlighted under:

sudo usermod -a <user_name> -G <group_name>

Here, the -a choice stands for append (add on the finish) and it provides the person to an current group and the -G flag is used to specify the title of the group to which the person is being appended. There is not any choice for verbose output with this command, besides it offers a warning if the person or the group doesn’t exist.

adding new user to group

Add User to Multiple Groups

The usermod command in Linux will also be used so as to add a person to a number of teams with basically the identical choices as a single group, as proven under. Be positive to specify the group names with none areas.

sudo usermod -a <user_name> -G <group_name_1>,<group_name_2>,<group_name_3>

Create a New User and Assign a Group

You can add a brand new person to a gaggle all with a single command om Linux. The useradd command helps you to create a brand new person after which add a person to the desired teams. The syntax so as to add a brand new person using the useradd command is:

sudo useradd <username> -G <group_name_1>,<group_name_2>,<group_name_3>

creating new user and adding to groups in single command

View a User’s Groups

To view all of the teams related to a person, you should use both the teams command or the id command. Check you the syntax proven under:

teams <user_name>

id <user_name>

If the <user_name> is left clean, then it is going to present the group names for the present person solely.

listing the group of the user test1

How to Remove a User from a Group

To take away a person from a gaggle in Linux distros, you should use the gpasswd command, as per the syntax given under:

sudo gpasswd -d <user_name> <group_name>

In addition to eradicating a person from a gaggle, the gpasswd command can also be used for varied administrative duties reminiscent of defining group directors or setting a gaggle password, and many others.

Removing user test from the group sudo

Delete a Group in Linux

To delete any secondary group in Linux, you should use the groupdel command:

sudo groupdel <groupname>

Delete a group in Linux

How to Change a User’s Primary Group

All the instructions now we have mentioned until now apply to the secondary group and their customers. To change a person’s main group in Linux, use the next syntax:

sudo usermod –g <new_primary_group> <user_name>

You should be questioning what’s the distinction between the -g and -G flags. The -g flag is used for main teams, whereas the -G flag is used for secondary teams.

Changing the primary group for the user "test"

How to List All User Groups in Linux

A person which will get created on the time of set up is called a system person and is a part of many default teams in Linux. The details about each group within the system is saved within the file – /and many others/group. To checklist all teams within the system, use the next syntax:

sudo cat /and many others/group

Listing all user groups in the system

Manage Users and Groups in Linux Terminal

Managing teams is a helpful activity that would turn out to be useful throughout varied operations, particularly in case you are a system administrator. Here, now we have proven you some straightforward Linux Terminal instructions to create a brand new person, create new teams, add a brand new person to a gaggle, and more. So, we hope this text solves your issues. If it doesn’t, tell us within the feedback under, and we’ll enable you to out.


Check out more article on – How-To tutorial and latest highlights on – Technical News


Tags: AddFix IssueFix Software IssuesFix Technical IssuesGroupGuideHow To FixHow To Fix IssueHow-To-9-How-ToLinuxTechnical TroubleshootingUser

Recommended.

How to Make a Minecraft Villager Trading Hall in 2022 (Guide)

How to Make a Minecraft Villager Trading Hall in 2022 (Guide)

December 24, 2022
How to Fix Safari Disappeared from Home Screen on iPhone

How to Fix Safari Disappeared from Home Screen on iPhone

March 12, 2023

Trending.

No Content Available
  • About
  • Advertise
  • Privacy & Policy
  • Contact
All about technical, android, mobile, windows relating website. We provide you with the latest technology straight from the industry.

© 2023 How To Fix Issue - All rights reserved.

No Result
View All Result
  • Home
  • Windows
    • Windows 10
    • Windows 11
  • Mac
  • iOS
  • iPad
  • iPhone
  • Social Media
  • News

© 2023 How To Fix Issue - All rights reserved.

Welcome Back!

Login to your account below

Forgotten Password?

Retrieve your password

Please enter your username or email address to reset your password.

Log In
We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept”, you consent to the use of ALL the cookies.
Do not sell my personal information.
Cookie SettingsAccept
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
SAVE & ACCEPT
This website uses cookies. By continuing to use this website you are giving consent to cookies being used. Visit our Privacy and Cookie Policy.