Linux (about groups)

Let's understand groups </ b> as a concept when managing users. "Files that can be viewed only by Group A" "Files that can be written and viewed only by Group B" It is used when managing access rights as described above.

The user must belong to some group. You can join more than one group. Last time I created a user with useradd </ b>. Actually, a group was also created at that time, and it belongs to the group. Try entering the groups </ b> command. You can check the group you belong to.

neko     $  groups
neko:neko

You will belong to the neko group. There are two types of groups, primary groups </ b> and subgroups </ b>. Roughly speaking, the most basic group is the primary group </ b>, and the other groups are subgroups </ b>.

groupadd

Let's actually create a group. It can be created with the groupadd command. This time we will create a nyanya group.
root     #  groupadd nyanya

Use / etc / group </ b> to check the created group. You should see the nyanya group on the last line.

root     #  cat /etc/group

usermod

Join the user to the created group. Use the usermod </ b> command. usermod </ b> allows you to change user settings. In this case, you will join the group, so use the -G (Group) option. Add the neko user to the nyanya group.

root     # usermod -G nyanya neko

Use the gruops </ b> command to check.

groups neko
neko : neko nyanya 

I was able to join the nyanya group.

groupdel

Let's delete the group. Use groupdel </ b>. Delete the nyanya group.

root      # groupdel nyanya

Let's check with the groups </ b> command. Please note that you cannot delete the primary group. It is possible that some users will not belong to the group.

that's all,,

         
  • groups
  •   
  • groupadd
  •   
  • usermod
  •   
  • groupdel

It was about the group.

Next → About files and directories

Recommended Posts