groupadd command-add a group

You can add a group with the groupadd command . Execute with root privileges with sudo.

sudo groupadd group name

The following is a sample to create a group "myapp-group" for an application.

sudo groupadd myapp-group

To check the list of groups, output the "/ etc / group" file with the cat command.

sudo cat / etc / group

Make sure myapp-group exists.

myapp-group: x: 1003:

What do you need a group for?

Creating a group has multiple purposes, but I will write when it is necessary for system development.

When multiple users save files in a directory

If multiple users store files in a directory for storing data, you need to create a group so that the group can read and write the file.

It is safer to limit users so that only users who belong to a specific group can read and write, rather than allowing all users to read and write.

Suppose kimoto, tanaka, and yamada are developing with their own users. In this case, writing the file to the data directory is in each user's group.

If tanaka wrote it, it will be "tanaka: tanaka". Then kimoto cannot read or write.

I'll explain how to avoid this elsewhere, but in such cases, you first need to create a group for your application.

Other operations on the group

The following article explains how to display the list of groups.

The following article explains how to delete a group.

Associated Information