Does anyone have the Red Hat Lab: Control Access to Files 2026, updated line by line of code?
Lab: Control Access to Files
Set standard permissions on files and interpret the security effects of different permission settings.
Outcomes
- Create a directory where users can work collaboratively on files.
- Create the required file and directory structure, assigning access rights as requested.
As the student user on the workstation machine, run the following lab command to prepare your environment for this exercise, and to ensure that all required resources are available:
student@workstation:~$
lab start perms-review
Instructions
The lab start command creates the dev1 and dev2 users, who are members of the techdocs group. The command also creates the dbadmin1 user, who does not belong to this group.
In this activity, you create the techdocs collaborative directory and configure it as follows:
- In the
techdocsdirectory, users add files and subdirectories for the exclusive use of thetechdocsgroup. Other users on the system are not allowed to have any access to the directory. - All new content created in the directory must inherit the
techdocsgroup ownership. - The
techdocsdirectory must be configured so that only the owner of a file can delete it.
Ensure that the user file creation mask is configured persistently for the dev1 and dev2 users to enable group collaboration and to prohibit all other users from accessing their data.
To validate your configuration of the techdocs directory, create the following subdirectories and files as the dev1 and dev2 users to ensure that their level of access complies with requirements:
| Directory | Owner | Group | Files |
|---|---|---|---|
dev1 |
dev1 |
techdocs |
dev1.txt |
dev1.log |
|||
dev1.cfg |
|||
dev2 |
dev2 |
techdocs |
dev2.txt |
dev2.log |
|||
dev2.cfg |
|||
- Log in to the
serverbmachine as thestudentuser, and then switch to therootuser.- Log in to the
serverbmachine as thestudentuser and switch to therootuser. Usestudentas the password.student@workstation:~$ssh student@serverb...output omitted... [student@serverb ~]$sudo -i[sudo] password for student:student[root@serverb ~]#
- Log in to the
- Create the
techdocscollaborative directory under the/homedirectory. Set the group ownership of the directory to thetechdocsgroup, grant full permissions to the user and the owning group, and disallow all access for others on the system. Configure the directory so that all new content is owned by thetechdocsgroup and only file owners can delete their files.- Create a
/home/techdocsdirectory.[root@serverb ~]#mkdir /home/techdocs - Change the group ownership for the
/home/techdocsdirectory to thetechdocsgroup.[root@serverb ~]#chown :techdocs /home/techdocs - Set read, write, and execute permissions for user and group, and no permission for others on the
/home/techdocsdirectory.[root@serverb ~]#chmod 770 /home/techdocs - Set the special SGID permission on the directory to ensure that all new content inherits the
techdocsgroup ownership.[root@serverb ~]#chmod g+s /home/techdocs - Assign the
stickybit to the/home/techdocsdirectory.[root@serverb ~]#chmod o+t /home/techdocs - List the directory's permissions.[root@serverb ~]#
ls -ld /home/techdocsdrwxrws--T. 2 root techdocs 6 Oct 6 20:40 /home/techdocs
- Create a
- Persistently configure the user file creation mask in the shell for the
dev1anddev2users so that group members can collaborate, but other users cannot access their data.- Switch to the
dev1user and set theumaskattribute of the shell to007.[root@serverb ~]#su - dev1[dev1@serverb ~]$umask 007 - Configure the
umaskvalue persistently by updating the~/.bashrcstartup file for Bash.[dev1@serverb ~]$echo "umask 007" >> ~/.bashrc - To test the directory configuration, create the specified
dev1subdirectory in the/home/techdocsteam directory, and create thedev1.txt,dev1.log, anddev1.cfgfiles.[dev1@serverb ~]$cd /home/techdocs/[dev1@serverb techdocs]$mkdir dev1[dev1@serverb techdocs]$touch dev1/dev1{.txt,.log,.cfg} - List the contents of the
dev1directory.[dev1@serverb techdocs]$ls -l dev1* total 0 -rw-rw----. 1 dev1 techdocs 0 Oct 6 20:43 dev1.cfg -rw-rw----. 1 dev1 techdocs 0 Oct 6 20:43 dev1.log -rw-rw----. 1 dev1 techdocs 0 Oct 6 20:43 dev1.txt - Exit from the
dev1user shell. Switch to thedev2user.[dev1@serverb techdocs]$exitlogout [root@serverb ~]#su - dev2[dev2@serverb ~]$ - Set the
umaskattribute of the user's shell to007and configure it persistently.[dev2@serverb ~]$umask 007[dev2@serverb ~]$echo "007" >> ~/.bashrc - Create the specified
dev2subdirectory in the/home/techdocsteam directory along with the necessary files.[dev2@serverb ~]$cd /home/techdocs/[dev2@serverb techdocs]$mkdir dev2[dev2@serverb techdocs]$touch dev2/dev2{.txt,.log,.cfg} - List the contents of the
dev2directory.[dev2@serverb techdocs]$ls -l dev2* total 0 -rw-rw----. 1 dev2 techdocs 0 Oct 6 21:08 dev2.cfg -rw-rw----. 1 dev2 techdocs 0 Oct 6 21:08 dev2.log -rw-rw----. 1 dev2 techdocs 0 Oct 6 21:08 dev2.txt
- Switch to the
- Verify that users in the
techdocsgroup can create and collaborate on content in the/home/techdocsdirectory. As thedev2user, modify the/home/techdocs/dev1/dev1.logfile with the following content:Logging started.- Update the
/home/techdocs/dev1/dev1.logfile as described, and then display the file content.[dev2@serverb techdocs]$echo "Logging started" >> dev1/dev1.log[dev2@serverb techdocs]$cat dev1/dev1.logLogging started
- Update the
- Verify that members of the
techdocgroup can delete only their own files. As thedev2user, try to delete the/home/techdocs/dev1directory, which should fail.- As the
dev2user, try to delete the/home/techdocs/dev1directory. This attempt fails because the sticky bit is set on thetechdocsdirectory.[dev2@serverb techdocs]$rm -rf dev1rm: cannot remove 'dev1': Operation not permitted
- As the
- Verify that only users in the
techdocsgroup can access the/home/techdocscollaborative directory. As thedbadmin1user, try to access the/home/techdocsdirectory, which should fail.- Exit from the
dev2user shell. Switch to thedbadmin1user. Change to the/home/techdocsdirectory.[dev2@serverb techdocs]$exitlogout [root@serverb ~]#su - dbadmin1[dbadmin1@serverb ~]$cd /home/techdocs/-bash: cd: /home/techdocs/: Permission denied [dbadmin1@serverb ~]$ - Exit from the
dbadmin1user shell.[dbadmin1@serverb ~]$exitlogout [root@serverb ~]#
- Exit from the
- After completing the tasks of this activity, return to the
workstationmachine as thestudentuser.[root@serverb ~]#exitlogout [student@serverb ~]$exitConnection to serverb closed. student@workstation:~$
Evaluation
As the student user on the workstation machine, use the lab command to grade your work. Correct any reported failures and rerun the command until successful.
student@workstation:~$
lab grade perms-review
Finish
On the workstation machine, change to the student user home directory and use the lab command to complete this exercise. This step is important to ensure that resources from previous exercises do not impact upcoming exercises.
student@workstation:~$
lab finish perms-review
1
5
u/No_Rhubarb_7222 Red Hat Employee 2d ago
What you’ve pasted is a lab from Red Hat Training. Things like the ‘lab’ command and grading stuff is provided within the training environment. I’m not aware of someone having identically written material or scripting available elsewhere. Usually, other providers, like Sander, have their own versions of labs and infrastructure.