r/redhat • • 2d ago

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 techdocs directory, users add files and subdirectories for the exclusive use of the techdocs group. 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 techdocs group ownership.
  • The techdocs directory 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
  1. Log in to the serverb machine as the student user, and then switch to the root user.
    1. Log in to the serverb machine as the student user and switch to the root user. Use student as the password.student@workstation:~$ ssh student@serverb ...output omitted... [student@serverb ~]$ sudo -i [sudo] password for student: student [root@serverb ~]#
  2. Create the techdocs collaborative directory under the /home directory. Set the group ownership of the directory to the techdocs group, 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 the techdocs group and only file owners can delete their files.
    1. Create a /home/techdocs directory.[root@serverb ~]# mkdir /home/techdocs
    2. Change the group ownership for the /home/techdocs directory to the techdocs group.[root@serverb ~]# chown :techdocs /home/techdocs
    3. Set read, write, and execute permissions for user and group, and no permission for others on the /home/techdocs directory.[root@serverb ~]# chmod 770 /home/techdocs
    4. Set the special SGID permission on the directory to ensure that all new content inherits the techdocs group ownership.[root@serverb ~]# chmod g+s /home/techdocs
    5. Assign the sticky bit to the /home/techdocs directory.[root@serverb ~]# chmod o+t /home/techdocs
    6. List the directory's permissions.[root@serverb ~]# ls -ld /home/techdocs drwxrws--T. 2 root techdocs 6 Oct 6 20:40 /home/techdocs
  3. Persistently configure the user file creation mask in the shell for the dev1 and dev2 users so that group members can collaborate, but other users cannot access their data.
    1. Switch to the dev1 user and set the umask attribute of the shell to 007.[root@serverb ~]# su - dev1 [dev1@serverb ~]$ umask 007
    2. Configure the umask value persistently by updating the ~/.bashrc startup file for Bash.[dev1@serverb ~]$ echo "umask 007" >> ~/.bashrc
    3. To test the directory configuration, create the specified dev1 subdirectory in the /home/techdocs team directory, and create the dev1.txt, dev1.log, and dev1.cfg files.[dev1@serverb ~]$ cd /home/techdocs/ [dev1@serverb techdocs]$ mkdir dev1 [dev1@serverb techdocs]$ touch dev1/dev1{.txt,.log,.cfg}
    4. List the contents of the dev1 directory.[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
    5. Exit from the dev1 user shell. Switch to the dev2 user.[dev1@serverb techdocs]$ exit logout [root@serverb ~]# su - dev2 [dev2@serverb ~]$
    6. Set the umask attribute of the user's shell to 007 and configure it persistently.[dev2@serverb ~]$ umask 007 [dev2@serverb ~]$ echo "007" >> ~/.bashrc
    7. Create the specified dev2 subdirectory in the /home/techdocs team 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}
    8. List the contents of the dev2 directory.[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
  4. Verify that users in the techdocs group can create and collaborate on content in the /home/techdocs directory. As the dev2 user, modify the /home/techdocs/dev1/dev1.log file with the following content: Logging started.
    1. Update the /home/techdocs/dev1/dev1.log file as described, and then display the file content.[dev2@serverb techdocs]$ echo "Logging started" >> dev1/dev1.log [dev2@serverb techdocs]$ cat dev1/dev1.log Logging started
  5. Verify that members of the techdoc group can delete only their own files. As the dev2 user, try to delete the /home/techdocs/dev1 directory, which should fail.
    1. As the dev2 user, try to delete the /home/techdocs/dev1 directory. This attempt fails because the sticky bit is set on the techdocs directory.[dev2@serverb techdocs]$ rm -rf dev1 rm: cannot remove 'dev1': Operation not permitted
  6. Verify that only users in the techdocs group can access the /home/techdocs collaborative directory. As the dbadmin1 user, try to access the /home/techdocs directory, which should fail.
    1. Exit from the dev2 user shell. Switch to the dbadmin1 user. Change to the /home/techdocs directory.[dev2@serverb techdocs]$ exit logout [root@serverb ~]# su - dbadmin1 [dbadmin1@serverb ~]$ cd /home/techdocs/ -bash: cd: /home/techdocs/: Permission denied [dbadmin1@serverb ~]$
    2. Exit from the dbadmin1 user shell.[dbadmin1@serverb ~]$ exit logout [root@serverb ~]#
  7. After completing the tasks of this activity, return to the workstation machine as the student user.[root@serverb ~]# exit logout [student@serverb ~]$ exit Connection 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
0 Upvotes

3 comments sorted by

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.

4

u/jpwillz Red Hat Certified System Administrator 2d ago

You may want to be careful also because some of this may be proprietary from Red Hat.

1

u/Danielle18ja 2d ago

Now in members