02. Creating and Modifying Groups

Creating a Group

To create a group, use the groupadd command.

$ groupadd family
Specify group id (else, system will make one for you).
Force create a group, even if it already exists.
Change name of the group.
Allow duplicate groupnames to be created.
Create a system group ID (gid < 500).

Notice that there's an option to set the group ID to less than 500 with the -r option. All group ID's in this range are known a system processes and not real user-populated groups. You may check all current groups within the /etc/group file, which we'll go over in detail shortly.

Modifying a Group

To modify a group, use the groupmod command. Let's try renaming our family group to cousins.

$ groupmod -n cousins family

Deleting groups

To delete a group, simply use the groupdel command.

$ groupdel cousins

Here's some extra practice for using the above commands and options.

$ groupadd developers
# Check to see that the new group has been added
$ cat /etc/group
# Let's say we have a group with GID 1010 already
$ groupadd -g 1010 developers
# This should error out. Now let's allow duplicates
$ groupmod -o -g 1040 developers
# Rename 
$ groupmod -n cool-kids developers

Take your Linux skills to the next level!

Command Line Kung Fu

Take your Linux skills to the next level! Try Linux & UNIX

Command Line Kung Fu is packed with dozens of tips and practical real-world examples. You won't find theoretical examples in this book. The examples demonstrate how to solve actual problems. The tactics are easy to find, too. Each chapter covers a specific topic and groups related tips and examples together.

$ Check price
14.9914.99Amazon 4.5 logo(27+ reviews)

More Linux & UNIX resources

Want to avoid becoming a code monkey?

Pragmatic Thinking

Want to avoid becoming a code monkey? Try Good Practice

Programmers have to constantly learn new concepts and technologies. In this book by Andy Hunt, you'll learn how our brains are wired, and how to take advantage of your brain's architecture to make the most of your learning. You'll learn new tricks and tips to learn more, faster, and retain more of what you learn.

$ Check price
34.9534.95Amazon 4.5 logo(86+ reviews)

More Good Practice resources