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

Want to avoid becoming a code monkey?

Clean Code

Want to avoid becoming a code monkey? Try Good Practice

Software expert Robert C. Martin presents a revolutionary paradigm with Clean Code: A Handbook of Agile Software Craftsmanship. Martin has teamed up with his colleagues from Object Mentor to distill their best agile practice of cleaning code "on the fly" into a book that will instill within you the values of a software craftsman and make you a better programmer.

$ Check price
49.9949.99Amazon 4.5 logo(427+ reviews)

More Good Practice resources

Take your Linux skills to the next level!

The Linux Command Line

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

The Linux Command Line takes you from your very first terminal keystrokes to writing full programs in Bash, the most popular Linux shell. Along the way you'll learn the timeless skills handed down by generations of gray-bearded, mouse-shunning gurus: file navigation, environment configuration, command chaining, pattern matching with regular expressions, and more.

$ Check price
39.9539.95Amazon 4.5 logo(274+ reviews)

More Linux & UNIX resources