Skip to content

[Linux] How to add users to a specific group

Last Updated on 2020-09-08 by Clay

Linux is an operating system that can do all the functions you imagine

Introduction

The different groups maybe have different permissions in a Linux server, how to add user to a specific group is an important operator.

What I want to record today is about group operations in Linux system, for example: how to change user groups.


View your groups

If you want to view the user’s own group, you can use the following command:

groups

View all groups information

If you want to be able to view all the groups and who in this group, then you can use the following command:

cat /etc/group

Create group

If you want to create a specific (name) group, you can use the following command:

sudo groupadd "group_name"

group_name” is the name of the group you wish to create.


Change a user to a specific group

The following command is to change a specific user to a specific group:

sudo usermod --gid "group_name" "user_name"

If you want users to join a specific, plural groups, you can use the following command to join:

sudo usermod --append --groups "group_name_01", "group_name_02" "user_name"

After “–groups“, you can connect multiple group names, which allows users to join multiple groups at once, which is quite convenient.


My thoughts

How to configure groups settings is a seemingly inconspicuous but very important function in Linux, especially when Linux is used as a multi-person server.

Different groups can have different permissions and master control over different work areas, so that they will not conflict with each other and can work together. Therefore, I think it is necessary for administrators to clearly distinguish between users with different needs, or users who perform different tasks.

I hope that in the future more about groups in Linux, I can update them in this article together.


References


Read More

Tags:

Leave a ReplyCancel reply

Exit mobile version