In this lab, you 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 serverb as the student user.
Run the sudo -i command at the shell prompt to become the root user.
Use student as the student user password.
Create a /home/techdocs directory.
Change the group ownership of the /home/techdocs directory to the techdocs group.
Verify that users in the techdocs group cannot create files in the /home/techdocs directory.
Use the su command to switch to the tech1 user.
[root@serverb ~]# su - tech1
[tech1@serverb ~]$Create a techdoc1.txt file in the /home/techdocs directory.
This step should fail.
Although the /home/techdocs directory is owned by the techdocs group and tech1 is part of the techdocs group, you cannot create a file in that directory.
The reason is because the techdocs group does not have write permission.
[tech1@serverb ~]$ touch /home/techdocs/techdoc1.txt
touch: 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/techdocs directory.
On the /home/techdocs directory, configure setgid (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 techdocs group now has write permission.
Confirm that users in the techdocs group can now create and edit files in the /home/techdocs directory.
Users that are not in the techdocs group cannot edit or create files in the /home/techdocs directory.
The tech1 and tech2 users are in the techdocs group.
The database1 user is not in that group.
Switch to the tech1 user.
Create a techdoc1.txt file in the /home/techdocs directory.
Add some text to the /home/techdocs/techdoc1.txt file.
Exit from the tech1 user 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 tech2 user.
Display the content of the /home/techdocs/techdoc1.txt file.
Create a techdoc2.txt file in the /home/techdocs directory.
Exit from the tech2 user 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 database1 user.
Display the content of the /home/techdocs/techdoc1.txt file.
You get a Permission Denied message.
Verify that the database1 user does not have access to the file.
Exit from the database1 user shell.
Enter the following long echo command 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.defs file 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 student user.
Switch to the student login shell.
When done, exit from the shell.
[root@serverb ~]#su - student[student@serverb ~]$umask0022 [student@serverb ~]$exitlogout [root@serverb ~]#
Edit the /etc/login.defs file and set a umask of 007.
The /etc/login.defs file 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 student user, verify that the global umask changes to 007.
[root@serverb ~]#exitlogout [student@serverb ~]$exitlogout Connection to serverb closed. [student@workstation ~]$ssh student@serverb...output omitted... [student@serverb ~]$umask0007
Return to the workstation system as the student user.
[student@serverb ~]$ exit
logout
Connection to serverb closed.
[student@workstation ~]$This concludes the section.