RHCSA Rapid Track
Control the permissions on files that are created in a directory by using umask settings and the setgid permission.
Outcomes
Create a shared directory where the
operatorsgroup automatically owns new files.Experiment with various umask settings.
Adjust default permissions for specific users.
Verify your change.
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-default
Instructions
Log in to the
serverasystem as thestudentuser.[student@workstation ~]$
ssh student@servera...output omitted... [student@servera ~]$Switch to the
operator1user withredhatas the password.[student@servera ~]$
su - operator1Password:redhat[operator1@servera ~]$List the
operator1user's default umask value.[operator1@servera ~]$
umask0022Create a
/tmp/shareddirectory. In the/tmp/shareddirectory, create adefaultsfile. Look at the default permissions.Create the
/tmp/shareddirectory. List the permissions of the new directory.[operator1@servera ~]$
mkdir /tmp/shared[operator1@servera ~]$ls -ld /tmp/shareddrwxr-xr-x. 2 operator1 operator1 6 Feb 4 14:06 /tmp/sharedCreate a
defaultsfile in the/tmp/shareddirectory.[operator1@servera ~]$
touch /tmp/shared/defaultsList the permissions of the new file.
[operator1@servera ~]$
ls -l /tmp/shared/defaults-rw-r--r--. 1 operator1 operator1 0 Feb 4 14:09 /tmp/shared/defaults
Change the group ownership of the
/tmp/shareddirectory to theoperatorsgroup. Confirm the new ownership and permissions.Change the group ownership of the
/tmp/shareddirectory to theoperatorsgroup.[operator1@servera ~]$
chown :operators /tmp/sharedList the permissions of the
/tmp/shareddirectory.[operator1@servera ~]$
ls -ld /tmp/shareddrwxr-xr-x. 2 operator1 operators 22 Feb 4 14:09 /tmp/sharedCreate a
groupfile in the/tmp/shareddirectory. List the file permissions.[operator1@servera ~]$
touch /tmp/shared/group[operator1@servera ~]$ls -l /tmp/shared/group-rw-r--r--. 1 operator1 operator1 0 Feb 4 17:00 /tmp/shared/groupNote
The group owner of the
/tmp/shared/groupfile is notoperatorsbutoperator1.
Ensure that the
operatorsgroup owns files that are created in the/tmp/shareddirectory.Set the group ID to the
operatorsgroup for the/tmp/shareddirectory.[operator1@servera ~]$
chmod g+s /tmp/sharedCreate a
ops_db.txtfile in the/tmp/shareddirectory.[operator1@servera ~]$
touch /tmp/shared/ops_db.txtVerify that the
operatorsgroup is the group owner for the new file.[operator1@servera ~]$
ls -l /tmp/shared/ops_db.txt-rw-r--r--. 1 operator1 operators 0 Feb 4 16:11 /tmp/shared/ops_db.txt
Create an
ops_net.txtfile in the/tmp/shareddirectory. Record the ownership and permissions. Change the umask for theoperator1user. Create anops_prod.txtfile. Record the ownership and permissions of theops_prod.txtfile.Create an
ops_net.txtfile in the/tmp/shareddirectory.[operator1@servera ~]$
touch /tmp/shared/ops_net.txtList the permissions of the
ops_net.txtfile.[operator1@servera ~]$
ls -l /tmp/shared/ops_net.txt-rw-r--r--. 1 operator1 operators 5 Feb 0 15:43 /tmp/shared/ops_net.txtChange the umask for the
operator1user to 027. Confirm the change.[operator1@servera ~]$
umask 027[operator1@servera ~]$umask0027Create an
ops_prod.txtfile in the/tmp/shared/directory. Verify that newly created files have read-only access for theoperatorsgroup and no access for other users.[operator1@servera ~]$
touch /tmp/shared/ops_prod.txt[operator1@servera ~]$ls -l /tmp/shared/ops_prod.txt-rw-r-----. 1 operator1 operators 0 Feb 0 15:56 /tmp/shared/ops_prod.txt
Open a new terminal window and log in to
serveraasoperator1.[student@workstation ~]$
ssh operator1@servera...output omitted... [operator1@servera ~]$List the umask value for
operator1.[operator1@servera ~]$
umask0022Change the default umask for the
operator1user. The new umask prohibits all access for users that are not in their group. Confirm that the umask is changed.Change the default umask for the
operator1user to 007.[operator1@servera ~]$
echo "umask 007" >> ~/.bashrc[operator1@servera ~]$cat ~/.bashrc# .bashrc # Source global definitions if [ -f /etc/bashrc ]; then . /etc/bashrc fi ...output omitted...umask 007Log out and log in again as the
operator1user. Confirm that the change is permanent.[operator1@servera ~]$
exitlogout Connection to servera closed. [student@workstation ~]$ssh operator1@servera...output omitted... [operator1@servera ~]$umask0007
Create an
ops_prod2.txtfile in the/tmp/shared/directory. Verify that newly created files have read and write access for theoperatorsgroup and no access for other users, due to the new umask of 007.[operator1@servera ~]$
touch /tmp/shared/ops_prod2.txt[operator1@servera ~]$ls -l /tmp/shared/ops_prod2.txt-rw-rw----. 1 operator1 operators 0 Feb 0 15:56 /tmp/shared/ops_prod2.txtOn
servera, close alloperator1andstudentuser shells. Return to theworkstationsystem as thestudentuser.Warning
Failure to exit from all
operator1shells causes the finish script to fail.[operator1@servera ~]$
exitlogout Connection to servera closed. [student@workstation ~]$