RHCSA Rapid Track
Course update
An updated version of this course is available that uses a newer version of Red Hat Enterprise Linux in the lab environment. Therefore, the RHEL 9.0 version of the lab environment will retire on December 31, 2024. Please complete any work in this lab environment before it is removed on December 31, 2024. For the most up-to-date version of this course, we recommend moving to the RHEL 9.3 version.
In this exercise, you use file system permissions to create a directory in which all members of a particular group can add and delete files.
Outcomes
Create a collaborative directory that all members of a group can access.
As the student user on the workstation machine, use the lab command to prepare your system for this exercise.
This command prepares your environment and ensures that all required resources are available.
[student@workstation ~]$ lab start perms-cli
Instructions
From
workstation, log in toserveraas thestudentuser and switch to therootuser.[student@workstation ~]$
ssh student@servera...output omitted... [student@servera ~]$sudo -i[sudo] password for student:student[root@servera ~]#Create the
/home/consultantsdirectory.[root@servera ~]#
mkdir /home/consultantsChange the group ownership of the
consultantsdirectory toconsultants.[root@servera ~]#
chown :consultants /home/consultantsModify the permissions of the
consultantsgroup to allow its group members to create files in, and delete files from, the/home/consultantsdirectory.The current permissions forbid others from accessing the files. You must set the appropriate permissions.
Verify that the permissions of the
consultantsgroup allow its group members to create files in, and delete files from, the/home/consultantsdirectory.Note that the
consultantsgroup currently does not have write permission.[root@servera ~]#
ls -ld /home/consultantsdrwxr-xr-x. 2 root consultants 6 Mar 1 12:08 /home/consultantsAdd write permission to the
consultantsgroup. Use the symbolic method for setting the appropriate permissions.[root@servera ~]#
chmod g+w /home/consultants[root@servera ~]#ls -ld /home/consultantsdrwxrwxr-x. 2 root consultants 6 Mar 1 13:21 /home/consultantsForbid others from accessing files in the
/home/consultantsdirectory. Use the octal method for setting the appropriate permissions.[root@servera ~]#
chmod 770 /home/consultants[root@servera ~]#ls -ld /home/consultantsdrwxrwx---. 2 root consultants 6 Mar 1 12:08 /home/consultants/
Exit the
rootshell and switch to theconsultant1user. The password isredhat.[root@servera ~]#
exitlogout [student@servera ~]$su - consultant1Password:redhat[consultant1@servera ~]$Navigate to the
/home/consultantsdirectory and create a file calledconsultant1.txt.Change to the
/home/consultantsdirectory.[consultant1@servera ~]$
cd /home/consultantsCreate an empty file called
consultant1.txt.[consultant1@servera consultants]$
touch consultant1.txt
List the default user and group ownership of the new file and its permissions.
[consultant1@servera consultants]$
ls -l consultant1.txt-rw-rw-r--. 1 consultant1 consultant1 0 Mar 1 12:53 consultant1.txtEnsure that all members of the
consultantsgroup can edit theconsultant1.txtfile. Change the group ownership of theconsultant1.txtfile toconsultants.Use the
chowncommand to change the group ownership of theconsultant1.txtfile toconsultants.[consultant1@servera consultants]$
chown :consultants consultant1.txtList the new ownership of the
consultant1.txtfile.[consultant1@servera consultants]$
ls -l consultant1.txt-rw-rw-r--. 1 consultant1 consultants 0 Mar 1 12:53 consultant1.txt
Exit the shell and switch to the
consultant2user. The password isredhat.[consultant1@servera consultants]$
exitlogout [student@servera ~]$su - consultant2Password:redhat[consultant2@servera ~]$Navigate to the
/home/consultantsdirectory. Ensure that theconsultant2user can add content to theconsultant1.txtfile.Change to the
/home/consultantsdirectory. Addtextto theconsultant1.txtfile.[consultant2@servera ~]$
cd /home/consultants/[consultant2@servera consultants]$echo "text" >> consultant1.txtVerify that the text is present in the
consultant1.txtfile.[consultant2@servera consultants]$
cat consultant1.txttextReturn to the
workstationsystem as thestudentuser.[consultant2@servera consultants]$
exitlogout [student@servera ~]$exitlogout Connection to servera closed. [student@workstation ~]$
This concludes the section.