31. Group Management Flashcards

1
Q

Learning Objectives

By the end of this chapter, you should be able to:

A
  • Explain why it is useful to have Linux users belong to one or more groups.
  • Use utilities such as groupadd, groupdel, groupmod, and usermod to create, remove and manipulate groups and their membership.
  • Describe User Private Groups.
  • Explain the concept of group membership.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Groups

Where is the groups config file location?

A

/etc/group

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Groups

Describe the components of a record in the /etc/group file.

A

Inside /etc/group file

groupname:password:GID:user1,user2,…

  • groupname: is the name of the group
  • password: is the password place holder. Group passwords may be set, but only if /etc/gshadow exists
  • GID: is the group identifier. Values between 0 and 99 are for system groups. Values between 100 and GID_MIN (as defined in /etc/login.defs and usually the same as UID_MIN) are considered special. Values over GID_MIN are for UPG (User Private Groups)
  • user1,user2,…: is a comma-separated list of users who are members of the group. The user need not be listed here if this group is the user’s principal group.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Group Management

What is the command to add a new group?

A

groupadd

$ sudo groupadd -r -g 215 staff

🚩 Be very careful with the usermod -G command; the group list that follows is the complete list of groups, not just the changes. Any supplemental groups left out will be gone! Non-destructive use should utilize the -a option, which will preserve pre-existing group memberships when adding new ones.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Group Management

What is the command to remove a group?

A

groupdel

$ sudo groupdel newgroup

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Group Management

What is the command to modify a group and add new users?

A

groupmod

$ sudo groupmod -g 101 blah

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Group Management

What is the command to manage a user’s group memberships?

A

usermod

$ sudo usermod -G student,group1,group2 student

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Group Management

The group manipluation utilities modify which 2 group config files?

  • groupadd
  • groupdel
  • groupmod
  • usermod
A

/etc/group

/etc/gshadow (if it exists)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

User Private Groups

What is a User Private Group?

A

The idea behind UPGs is that each user will have his or her own group.

However, UPGs are not guaranteed to be private; additional members may be added to someone’s private group in /etc/group.

By default, users whose accounts are created with useradd have: primary GID = UID and the group name is also identical to the user name.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Group Membership

A Linux user has ___ primary group; this is listed in ___ and will also be listed in ___.

A
  • 1
  • /etc/passwd
  • /etc/group
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Group Membership

Group membership can be identified by running either of the following commands?

A
  • $ groups [user1 user2 …]
  • $ id -Gn [user1 user2 …]

With no arguments, either command reports on the current user. Note that the default groups can differ by distribution:

On CentOs:

[student@CentOS7 ~]$ groups
student

On Ubuntu:

student@ubuntu:~$ groups
student adm cdrom sudo dip plugdev lpadmin sambashare libvirt

How well did you know this?
1
Not at all
2
3
4
5
Perfectly