Administration – Adding Groups

Each new user is assigned to one or more groups. You can create groups at any time and add users to those groups. The permissions that each group has to use files and directories in Linux depend on how the group permission bits are set on each item.

Assigning users to a group allows you to attach ownership to files, directories, and applications so that those users can work together on a project or have common access to resources.

Commands similar to those for working with users are available for managing your groups. You can add groups (groupadd), change group settings (groupmod), delete groups (groupdel), and add and delete members from those groups (groupmems).

Here are some examples for adding new groups with the groupadd command:

Create new group with next available GID
$ sudo groupadd marketing

Create new group with GID of 1701
$ sudo groupadd -g 1701 sales

Create group with existing GID
$ sudo groupadd -o -g 74 mysshd

With the groupmod command, you can change the name or group ID of an existing group. Here are examples:

Modify myadmin to use GID 491
$ sudo groupmod -g 491 myadmin

Change name of myadmin group to myad
$ sudo groupmod -n myad myadmin

To remove an existing group, use the groupdel command. Here is an example:

Remove existing myad group
$ sudo groupdel myad

Keep in mind that removing a group or user doesn’t remove the files, directories, devices, or other items owned by that group or user. If you do a long listing (ls -l) of a file or directory assigned to a user or group that was deleted, the UID or GID of the deleted user or group is displayed.


About msotela

This blog is for anyone who wants to access the power of a Linux system as a systems administrator or user. You may be a Linux enthusiast, a Linux professional, or possibly a computer professional who is increasingly finding the Windows systems in your data center supplanted by Linux boxes.

Posted on September 23, 2009, in Unix/Linux. Bookmark the permalink. Leave a comment.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: