How To Add A User To A Group In Ubuntu
Introduction
In Linux, a group is a unit in which you tin manage privileges for several users simultaneously. Linux groups allow you to manage multiple user permissions quickly and hands.
In this tutorial learn how user groups piece of work in Linux, and how to add users to specific groups.
Prerequisites
- A system running Linux
- A user account with sudo or root privileges
- Access to a terminal window/command line (Ctrl-Alt-T, Ctrl-Alt-F2)
What is a User Group in Linux
In Linux, different users have different roles or responsibilities. Some users might demand the ability to execute applications, while others are restricted from accessing specific files and folders.
Groups permit y'all create categories of users with pre-set permissions. Instead of managing permissions for each user account, y'all can simply add a user to a group to grant the appropriate permissions.
Chief Group
The primary group is set to the logged-in user. Any files the user creates are automatically added to that group. A user can only vest to one primary group at a time. A principal group with the same name every bit the user is created, and any files created by the user are included in that grouping.
Secondary Groups
A user can belong to whatever number of secondary groups (including none). Secondary groups are created to manage individual files and software applications. Members of the grouping inherit the read, write, and execute privileges for that grouping.
How to Create a User Group
To create a new group, enter the following:
sudo groupadd new_group
Replace new_group
with the proper noun you want for your new group.
How to Add User to Grouping
Add an Existing User to an Existing Group
Use the adduser
command to add a user to a group:
sudo adduser user_name new_group
Use the useradd
control to add a user:
sudo useradd –G new_group user_name
You can likewise utilize the usermod
command to add a user to a grouping:
sudo usermod –a –Thousand group_name user_name
The usermod
command uses the –suspend
and –group
options to append the user to a particular group. Without using –append
, the user could be dropped from other groups.
Add a User to Multiple Groups at One time
Utilize the usermod command to specify multiple groups to add together to:
sudo usermod –a –G new_group,new_group2,new_group3 user_name
Create a User and Add to Group
This is useful for creating a new user on the fly for a specific software application. Enter the following:
sudo useradd –G new_group new_user
Side by side, assign a password to the new user:
sudo passwd new_user
Modify a Users Primary Group
All previous commands have been used to manage the secondary groups a user belongs to. In most cases, a user'south primary group is the same as their username.
To change a users master grouping, enter the control:
sudo usermod –1000 new_group user_name
The lower-case –thousand
specifies the main group. (Upper-case –G
refers to a secondary group.) A user can but have one primary group, so the old main grouping user_name won't be master anymore for this user.
How to Remove a User From a Grouping
The gpasswd
tool is used for managing groups. To remove a user from a group:
sudo gpasswd –d user_name new_group
Note: The gpasswd
tool tin besides be used for other authoritative tasks such every bit defining group administrators and setting a password for access to group resources. Use the Linux homo command man gpasswd
for details.
Delete a Group
To delete a grouping, use the control:
sudo groupdel new_group
How to Listing Groups in Linux
Linux comes with several different groups by default. Some of these, like the sudo grouping, can be used to grant permissions. Others are hidden, used for system tasks.
To view a list of groups on your organisation by displaying the /etc/groups file:
sudo nano /etc/groups
To display the groups that a user belongs to with the groups
command:
groups
The image above shows the groups that the logged-in user 'sofija' belongs to. Yous can brandish groups for a different user past specifying the username:
groups other_user
Another method to display the groups a user belongs to, including user ID (uid) and group ID (gid), is to utilise the id
control:
id user_name
Other Common Groups
There are a several common grouping names you might encounter in Linux:
- sudo – A fellow member of this grouping can use the sudo command to elevate their privileges
- cycle – This is an older method of granting sudo-like privileges
- cdrom – Allows the user to mount the optical drive
- adm – Allows the user to monitor Linux system logs
- lpadmin – Allows the user to configure printers
- plugdev – Allows the user to access external storage devices
Decision
You should now have a good understanding of Linux groups and how to add and remove members from those groups. For more information on specific commands, you lot can enter the human command to display a manual in your terminal window.
Was this article helpful?
Yes No
How To Add A User To A Group In Ubuntu,
Source: https://phoenixnap.com/kb/how-to-add-user-to-group-linux
Posted by: mumfordcoser1975.blogspot.com
0 Response to "How To Add A User To A Group In Ubuntu"
Post a Comment