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 to servera as the student user and switch to the root user.
[student@workstation ~]$ssh student@servera...output omitted... [student@servera ~]$sudo -i[sudo] password for student:student[root@servera ~]#
Create the /home/consultants directory.
[root@servera ~]# mkdir /home/consultantsChange the group ownership of the consultants directory to consultants.
[root@servera ~]# chown :consultants /home/consultantsModify the permissions of the consultants group to allow its group members to create files in, and delete files from, the /home/consultants directory.
The current permissions forbid others from accessing the files. You must set the appropriate permissions.
Verify that the permissions of the consultants group allow its group members to create files in, and delete files from, the /home/consultants directory.
Note that the consultants group currently does not have write permission.
[root@servera ~]# ls -ld /home/consultants
drwxr-xr-x. 2 root consultants 6 Mar 1 12:08 /home/consultantsAdd write permission to the consultants group.
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/consultants
Forbid others from accessing files in the /home/consultants directory.
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 root shell and switch to the consultant1 user.
The password is redhat.
[root@servera ~]#exitlogout [student@servera ~]$su - consultant1Password:redhat[consultant1@servera ~]$
Navigate to the /home/consultants directory and create a file called consultant1.txt.
Change to the /home/consultants directory.
[consultant1@servera ~]$ cd /home/consultantsCreate an empty file called consultant1.txt.
[consultant1@servera consultants]$ touch consultant1.txtList 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 consultants group can edit the consultant1.txt file.
Change the group ownership of the consultant1.txt file to consultants.
Use the chown command to change the group ownership of the consultant1.txt file to consultants.
[consultant1@servera consultants]$ chown :consultants consultant1.txtList the new ownership of the consultant1.txt file.
[consultant1@servera consultants]$ ls -l consultant1.txt
-rw-rw-r--. 1 consultant1 consultants 0 Mar 1 12:53 consultant1.txtExit the shell and switch to the consultant2 user.
The password is redhat.
[consultant1@servera consultants]$exitlogout [student@servera ~]$su - consultant2Password:redhat[consultant2@servera ~]$
Navigate to the /home/consultants directory.
Ensure that the consultant2 user can add content to the consultant1.txt file.
Change to the /home/consultants directory.
Add text to the consultant1.txt file.
[consultant2@servera ~]$cd /home/consultants/[consultant2@servera consultants]$echo "text" >> consultant1.txt
Verify that the text is present in the consultant1.txt file.
[consultant2@servera consultants]$ cat consultant1.txt
textReturn to the workstation system as the student user.
[consultant2@servera consultants]$exitlogout [student@servera ~]$exitlogout Connection to servera closed. [student@workstation ~]$
This concludes the section.