RHCSA Rapid Track
In this lab, you will control default permissions on new files using the umask command and setgid permission.
Outcomes
Create a shared directory where new files are automatically owned by the group
ateam.Experiment with various umask settings.
Adjust default permissions for specific users.
Confirm your adjustment is correct.
Reset your serverX system. Run lab permissions setup to create the alice account. The password for alice is password.
Log in as
aliceon yourserverXvirtual machine and open a window with a Bash prompt. Use the umask command without arguments to display Alice's default umask value.[alice@serverX ~]$umask0002Create a new directory
/tmp/sharedand a new file/tmp/shared/defaultsto see how the default umask affects permissions.[alice@serverX ~]$mkdir /tmp/shared[alice@serverX ~]$ls -ld /tmp/shareddrwxrwxr-x. 2 alice alice 6 Jan 26 18:43 /tmp/shared[alice@serverX ~]$touch /tmp/shared/defaults[alice@serverX ~]$ls -l /tmp/shared/defaults-rw-rw-r--. 1 alice alice 0 Jan 26 18:43 /tmp/shared/defaultsChange the group ownership of
/tmp/sharedtoateamand record the new ownership and permissions.[alice@serverX ~]$chown :ateam /tmp/shared[alice@serverX ~]$ls -ld /tmp/shareddrwxrwxr-x. 2 alice ateam 21 Jan 26 18:43 /tmp/sharedCreate a new file in
/tmp/sharedand record the ownership and permissions.[alice@serverX ~]$touch /tmp/shared/alice3[alice@serverX ~]$ls -l /tmp/shared/alice3-rw-rw-r--. 1 alice alice 0 Jan 26 18:46 /tmp/shared/alice3Ensure the permissions of
/tmp/sharedcause files created in that directory to inherit the group ownership ofateam.[alice@serverX ~]$chmod g+s /tmp/shared[alice@serverX ~]$ls -ld /tmp/shareddrwxrwsr-x. 2 alice ateam 34 Jan 26 18:46 /tmp/shared[alice@serverX ~]$touch /tmp/shared/alice4[alice@serverX ~]$ls -l /tmp/shared/alice4-rw-rw-r--. 1 alice ateam 0 Jan 26 18:48 /tmp/shared/alice4Change the umask for
alicesuch that new files are created with read-only access for the group and no access for other users. Create a new file and record the ownership and permissions.[alice@serverX ~]$umask 027[alice@serverX ~]$touch /tmp/shared/alice5[alice@serverX ~]$ls -l /tmp/shared/alice5-rw-r-----. 1 alice ateam 0 Jan 26 18:48 /tmp/shared/alice5Open a new Bash shell as
aliceand view the umask.[alice@serverX ~]$umask0002Change the default umask for
aliceto prohibit all access for users not in their group.[alice@serverX ~]#echo "umask 007" >> ~/.bashrc[alice@serverX ~]#cat ~/.bashrc# .bashrc # Source global definitions if [ -f /etc/bashrc ]; then . /etc/bashrc fi # Uncomment the following line if you don't like systemctl's auto-paging feature: # export SYSTEMD_PAGER= # User specific aliases and functions umask 007Log out and back into
serverXasaliceand confirm that the umask changes you made are persistent.[alice@serverX ~]$umask0007