Create, delete, and modify local groups and group memberships
Binbo is a RHEL Sysdmin at Red Hat:
- Her RHEL Server: Binbo_RHEL_Server_086
- Her username: binbo.harry
- Her professional preference: a professional RHEL Sysadmin NEVER runs Linux commands as the root user
- Her certifications: CompTIA Linux+, studying for LFCS exam
- Her task: Create, delete, and modify local groups and group memberships
Binbo needs to teach herself how to create, delete and modify local groups and group memberships on her RHEL Server. Please generate and explain several sample commands that will make her an expert of this RHEL LFCS objective.
To create, delete, and modify local groups and group memberships on a RHEL (Red Hat Enterprise Linux) server, Binbo can use various commands and techniques. Here are some examples that will help her master this objective:
- Creating a local group: Binbo can use the
groupaddcommand to create a new local group. Here's an example:- sudo groupadd developers
- This command will create a new group named "developers". Binbo should replace "developers" with the desired group name. By default, the group is created with the next available Group ID (GID) on the system.
- Deleting a local group: To delete a local group, Binbo can use the
groupdelcommand. Here's an example:- sudo groupdel developers
- This command will delete the group named "developers". Binbo should replace "developers" with the group she wants to delete. Note that if any users are still members of the group, she will need to remove them first.
- Modifying group properties: Binbo can use the
groupmodcommand to modify group properties such as the group name or GID. Here are a couple of examples:- sudo groupmod -n newname oldname
- This command will change the group named "oldname" to "newname". Binbo should replace "newname" and "oldname" with the appropriate names.
- sudo groupmod -g 5000 developers
- This command will change the GID of the "developers" group to 5000. Binbo can replace "developers" with the desired group name and "5000" with the desired GID.
- Adding users to a group: To add users to a group, Binbo can use the
usermodcommand with the-aGoption. Here's an example:- sudo usermod -aG developers john
- This command will add the user "john" to the "developers" group. Binbo can replace "developers" with the appropriate group name and "john" with the desired username. The
-aoption ensures that the user is appended to the group without affecting their existing group memberships.
- Removing users from a group: To remove users from a group, Binbo can use the
gpasswdcommand with the-doption. Here's an example:- sudo gpasswd -d john developers
- This command will remove the user "john" from the "developers" group. Binbo should replace "developers" with the appropriate group name and "john" with the desired username.
These are some of the command examples that Binbo can use to create, delete, and modify local groups and group memberships on her RHEL server. Remember to use sudo or have appropriate administrative privileges when executing these commands.
