Group Management Tools

Ubuntu provides several command-line tools for managing groups, but also provides graphical tools for such. Many experienced sysadmins prefer the command-line tools because they are quick and easy to use and can be included in scripts if the sysadmin desires to script a repetitive task.

Here are the most commonly used group management command-line tools: groupadd This command creates and adds a new group. groupdel This command removes an existing group.

groupmod This command creates a group name or GIDs but doesn't add or delete members from a group.

gpasswd This command creates a group password. Every group can have a group password and an administrator. Use the -a argument to assign a user as group administrator.

useradd -G The -G argument adds a user to a group during the initial user creation. (More arguments are used to create a user.)

usermod -G This command allows you to add a user to a group so long as the user is not logged in at the time.

grpck A command for checking the /etc/group file for typos.

As an example, there is a DVD-RW device (/dev/scd0) on our computer that the sysadmin wants a regular user named shelley to have access to. To grant shelley that access, we would follow these steps:

1. Add a new group with the groupadd command:

# groupadd dvdrw

2. Change the group ownership of the device to the new group with the chgrp command:

# chgrp dvdrw /dev/scd0

3. Add the approved user to the group with the usermod command:

# usermod -G dvdrw shelley

4. Make user shelley the group administrator with the gpasswd command so that she can add new users to the group:

# gpasswd -A shelley

Now, the user shelley has permission to use the DVD-RW drive, as would anyone else added to the group by the super user or shelley because she is now also the group administrator and can add users to the group.

The sysadmin can also use the graphical interface that Ubuntu provides, as shown in Figure 14.1. It is accessed as the Users and Groups item from the Administration menu item.

Figure 14.1. Use the arrows to add or remove a user to and from a group.

Figure 14.1. Use the arrows to add or remove a user to and from a group.

Note that the full set of group commands and options are not available from the graphical interface, limiting the usefulness of the GUI to a subset of the most frequently used commands. You learn more about using the Ubuntu User Manager GUI in the next section of this chapter.



Was this article helpful?

0 0

Post a comment