RHCSA Rapid Track
In this exercise, you will create groups, use them as supplementary groups for some users without changing those users' primary groups, and configure one of the groups with sudo access to run commands as root.
Outcomes
You should be able to:
Create groups and use them as supplementary groups.
Configure sudo access for a group.
Log in to workstation as student using student as the password.
On workstation, run lab users-group-manage start to start the exercise.
This script creates the necessary user accounts to set up the environment correctly.
[student@workstation ~]$lab users-group-manage start
From
workstation, open an SSH session toserveraasstudent.[student@workstation ~]$ssh student@servera...output omitted...[student@servera ~]$On
servera, switch torootusing sudo, inheriting the full environment of therootuser.[student@servera ~]$sudo su -[sudo] password for student:student[root@servera ~]#Create the
operatorssupplementary group with the GID of 30000.[root@servera ~]#groupadd -g 30000 operatorsCreate
adminas an additional supplementary group.[root@servera ~]#groupadd adminVerify that both the
operatorsandadminsupplementary groups exist.[root@servera ~]#tail /etc/group...output omitted... operators:x:30000: admin:x:30001:Ensure that the users
operator1,operator2andoperator3belong to the groupoperators.Add
operator1,operator2, andoperator3tooperators.[root@servera ~]#usermod -aG operators operator1[root@servera ~]#usermod -aG operators operator2[root@servera ~]#usermod -aG operators operator3Confirm that the users are successfully added to the group.
[root@servera ~]#id operator1uid=1002(operator1) gid=1002(operator1) groups=1002(operator1),30000(operators)[root@servera ~]#id operator2uid=1003(operator2) gid=1003(operator2) groups=1003(operator2),30000(operators)[root@servera ~]#id operator3uid=1004(operator3) gid=1004(operator3) groups=1004(operator3),30000(operators)
Ensure that the users
sysadmin1,sysadmin2andsysadmin3belong to the groupadmin. Enable administrative rights for all the group members ofadmin. Verify that any member ofadmincan run administrative commands.Add
sysadmin1,sysadmin2, andsysadmin3toadmin.[root@servera ~]#usermod -aG admin sysadmin1[root@servera ~]#usermod -aG admin sysadmin2[root@servera ~]#usermod -aG admin sysadmin3Confirm that the users are successfully added to the group.
[root@servera ~]#id sysadmin1uid=1005(sysadmin1) gid=1005(sysadmin1) groups=1005(sysadmin1),30001(admin)[root@servera ~]#id sysadmin2uid=1006(sysadmin2) gid=1006(sysadmin2) groups=1006(sysadmin2),30001(admin)[root@servera ~]#id sysadmin3uid=1007(sysadmin3) gid=1007(sysadmin3) groups=1007(sysadmin3),30001(admin)Examine
/etc/groupto verify the supplemental group memberships.[root@servera ~]#tail /etc/group...output omitted... operators:x:30000:operator1,operator2,operator3 admin:x:30001:sysadmin1,sysadmin2,sysadmin3Create the
/etc/sudoers.d/adminfile such that the members ofadminhave full administrative privileges.[root@servera ~]#echo "%admin ALL=(ALL) ALL" >> /etc/sudoers.d/adminSwitch to
sysadmin1(a member ofadmin) and verify that you can run a sudo command assysadmin1.[root@servera ~]#su - sysadmin1[sysadmin1@servera ~]$sudo cat /etc/sudoers.d/admin[sudo] password for sysadmin1:redhat%admin ALL=(ALL) ALLExit the
sysadmin1user's shell to return to therootuser's shell.[sysadmin1@servera ~]$exitlogout[root@servera ~]#Exit the
rootuser's shell to return to thestudentuser's shell.[root@servera ~]#exitlogout[student@servera ~]$Log off from
servera.[student@servera ~]$exitlogout Connection to servera closed.[student@workstation ~]$