6.8 Managing Linux Groups
In this lab, your task is to: Remove cflynn from the hr group. Preserve all other group memberships. View the /etc/group file or use the groups command to verify the changes.
* To view all groups cflynn belongs to 1. Type groups cflynn mgmt1, hr, it -> secondary group cflynn group -> primary group *change membership 1. Type usermod -G mgmt1,it cflynn 2. Type groups cflynn
In this lab, your task is to: Add the hr group as a secondary group for the mbrown and cflynn user accounts. When you're finished, view the /etc/group file or use the groups command to verify the changes. When the -g switch is used with the usermod command, it sets the primary group membership, not the secondary group membership.
*Add users to the hr group: 1. Type usermod -G hr mbrown 2. Repeat this for cflynn (usermod -G cflynn) *Verify group membership 1. Type groups mbrown 2. Type groups cflynn
Using the groupadd -p command overrides the settings found in which file?
/etc/login.defs
You are attempting to delete the temp group but are unable to. Which of the following is the MOST likely cause?
The primary group of an existing user cannot be deleted.
You are the administrator for a small company, and you need to add a new group of users to the system. The group's name is sales. Which command accomplishes this task?
addgroup sales
gpasswd
changes a group password groupname prompts for a new password -r: removes group password
groupadd
creates a new group options that override the settings in /etc/login/defs file; -g: defines group ID -p: defines group password -r: creates a system group
groups
displays the primary and secondary group membership for the specified user account
You have a group named Research on your system that needs a new password because a member of the group has left the company. Which of the following commands should you use?
gpasswd Research
Which of the following commands creates a new group and defines the group password?
groupadd -p
You have a group named temp_sales on your system. The group is no longer needed, so you should remove it. Which of the following commands should you use?
groupdel temp_sales
Which groupmod option changes the name of a group?
groupmod -n
You want to see which primary and secondary groups the dredford user belongs to. Enter the command you would use to display group memberships for dredford.
groups dredford
usermod
modifies group membership for user account -g: assigns a user to a primary group -G: assigns a user to a secondary group Follow the command with a comma-separated list of groups ex) usermod -G mgmtl, it cflynn -aG: assigns a user to a secondary group by appending the group to any groups the user already belongs to -G "": removes the user from all secondary group memberships Do not include a space between the quotes
groupmod
modifies the existing group groupname prompts for a new password -r: removes a group password -n rename the group name
groupdel
modifies the system files by deleting all entries that refer to the specified group the named group must exist You cannot remove primary group of any existing user Must remove the user before removing the group
Which of the following commands is used to change the current group ID during a login session?
newgrp
newgrp
used to change the current group ID during a login session user this when working in a directory in which all the files must have the same group ownership -flag: user's environment will be reinitialized as if the user had logged in
Linux group commands
used to manage group accounts and grup membership groupadd groupmod groupdel gpasswd newgrp usermod groups
Which command removes all secondary group memberships for specific user accounts?
usermod -G ""
Which of the following commands removes a user from all secondary group memberships?
usermod -G ""
Which of the following commands assigns a user to a primary group?
usermod -g
In this lab, your task is to: Rename the sales group to western_sales_division. Create the eastern_sales_division group. Remove aespinoza as a member of the western_sales_division group. Assign aespinoza as a member of the eastern_sales_division group. When you're finished, view the /etc/group file or use the groups command to verify the changes.
1. groupdmod -n western_sales_division sales 2. groupadd eastern_sales_division 3. usermod -G eastern_sales_division aespinoza (remove aespinoza from western_sales_division group and add to the new group)