RHCSA Rapid Track
Configure permissions on files and set up a directory that users in a particular group can use to share files on the local file system.
Outcomes
Create a directory where users can work collaboratively on files.
Create files that are automatically assigned group ownership.
Create files that are not accessible outside the group.
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-review
Instructions
Log in to
serverbas thestudentuser. Run thesudo -icommand at the shell prompt to become therootuser. Usestudentas thestudentuser password.Create a
/home/techdocsdirectory.Change the group ownership of the
/home/techdocsdirectory to thetechdocsgroup.Verify that users in the
techdocsgroup cannot create files in the/home/techdocsdirectory.Use the
sucommand to switch to thetech1user.[root@serverb ~]#
su - tech1[tech1@serverb ~]$Create a
techdoc1.txtfile in the/home/techdocsdirectory. This step should fail.Although the
/home/techdocsdirectory is owned by thetechdocsgroup andtech1is part of thetechdocsgroup, you cannot create a file in that directory. The reason is because thetechdocsgroup does not have write permission.[tech1@serverb ~]$
touch /home/techdocs/techdoc1.txttouch: cannot touch '/home/techdocs/techdoc1.txt': Permission deniedList the directory's permissions.
[tech1@serverb ~]$
ls -ld /home/techdocs/drwxr-xr-x. 2 root techdocs 6 Feb 5 16:05 /home/techdocs/
Set permissions on the
/home/techdocsdirectory. On the/home/techdocsdirectory, configuresetgid(2); read, write, and execute permissions (7) for the owner/user and group; and no permissions (0) for other users.Verify that the permissions are set correctly.
The
techdocsgroup now has write permission.Confirm that users in the
techdocsgroup can now create and edit files in the/home/techdocsdirectory. Users that are not in thetechdocsgroup cannot edit or create files in the/home/techdocsdirectory. Thetech1andtech2users are in thetechdocsgroup. Thedatabase1user is not in that group.Switch to the
tech1user. Create atechdoc1.txtfile in the/home/techdocsdirectory. Add some text to the/home/techdocs/techdoc1.txtfile. Exit from thetech1user shell.[root@serverb ~]#
su - tech1[tech1@serverb ~]$touch /home/techdocs/techdoc1.txt[tech1@serverb ~]$ls -l /home/techdocs/techdoc1.txt-rw-r--r--. 1 tech1 techdocs 0 Feb 5 16:42 /home/techdocs/techdoc1.txt [tech1@serverb ~]$echo "This is the first tech doc." > /home/techdocs/techdoc1.txt[tech1@serverb ~]$exitlogout [root@serverb ~]#Switch to the
tech2user. Display the content of the/home/techdocs/techdoc1.txtfile. Create atechdoc2.txtfile in the/home/techdocsdirectory. Exit from thetech2user shell.[root@serverb ~]#
su - tech2[tech2@serverb ~]$cd /home/techdocs[tech2@serverb techdocs]$cat techdoc1.txtThis is the first tech doc. [tech2@serverb techdocs]$touch /home/techdocs/techdoc2.txt[tech2@serverb techdocs]$ls -ltotal 4 -rw-r--r--. 1 tech1 techdocs 28 Feb 5 17:43 techdoc1.txt -rw-r--r--. 1 tech2 techdocs 0 Feb 5 17:45 techdoc2.txt [tech2@serverb techdocs]$exitlogout [root@serverb ~]#Switch to the
database1user. Display the content of the/home/techdocs/techdoc1.txtfile. You get aPermission Deniedmessage. Verify that thedatabase1user does not have access to the file. Exit from thedatabase1user shell.Enter the following long
echocommand on a single line:[root@serverb ~]#
su - database1[database1@serverb ~]$cat /home/techdocs/techdoc1.txtcat: /home/techdocs/techdoc1.txt: Permission denied [database1@serverb ~]$ls -l /home/techdocs/techdoc1.txtls: cannot access '/home/techdocs/techdoc1.txt': Permission denied [database1@serverb ~]$exitlogout [root@serverb ~]#
Modify the
/etc/login.defsfile to adjust the default umask for login shells. Normal users should have a umask setting that allows the user and group to create, write, and execute files and directories, and preventing other users from viewing, modifying, or executing new files and directories.Determine the umask of the
studentuser. Switch to thestudentlogin shell. When done, exit from the shell.[root@serverb ~]#
su - student[student@serverb ~]$umask0022 [student@serverb ~]$exitlogout [root@serverb ~]#Edit the
/etc/login.defsfile and set a umask of007. The/etc/login.defsfile already contains a umask definition. Search the file and update with the appropriate value.[root@serverb ~]#
cat /etc/login.defs...output omitted... UMASK 007 ...output omitted...As the
studentuser, verify that the global umask changes to007.[root@serverb ~]#
exitlogout [student@serverb ~]$exitlogout Connection to serverb closed. [student@workstation ~]$ssh student@serverb...output omitted... [student@serverb ~]$umask0007Return to the
workstationsystem as thestudentuser.[student@serverb ~]$
exitlogout Connection to serverb closed. [student@workstation ~]$