Search for question
Question

Ch 14- Setting Ownership and Permission Lab Exercises This lab must be performed on an MX Linux virtual (or physical) machine. Exploring File Ownership & Groups (Objective 5.4) 1. Boot up your MX Linux VM, launch virtual terminal 2, and log in as a regular user. 2. Type pwd. What is your present working directory? 3. Create a blank, empty file in your present working directory by typing touch FileA.txt. 4. Type Is -. The -I is a lowercase L (not the numeral one). Look at the file type character (first char). 5. According to Table 14.1, what file type does d indicate? What color is it (last field)? 6. Ref p. 272-273. Clear the screen and type Is - FileA.txt. Record the following about this file: 1) File type code: 2) 3 character Owner (User) permissions string (see Figure 14.2): 3) 3 character Group permissions string: 4) 3 character Other (World) permissions string: 5) File owner's username: 6) File's group name: 7) File size in bytes: 8) Time stamp: 9) Filename: 7. Using whoami, determine and record your username: 8. Record your present working directory: 9. Log in as root by typing su -J. Don't forget the dash (-) after su! Enter the root password. 10. Type pwd and record it here: 11. Now use the cd command to move to the directory you recorded above. Type pwd to verify. 12. What command did you use? 13. Type Is - FileA.txt. 14. Try to change the ownership of the file. Type chown root FileA.txtJJ. 15. Remember that no news is good news. Did you get an error message? 16. Recall the Is - FileA.txt command. What is the file owner's username now? 17. Change the file's ownership back to the original owner. What command did you use? 18. Verify success by recalling the Is - FileA.txt command. 19. Log out of the root account by typing exit. 20. Now try to change file ownership using a standard user account: chown root FileA.txt. 21. What message did you receive? 22. Log back into the root account using su J. 23. Verify / move to the regular user's home dir you recorded above. Recall the Is - FileA.txt command 24. Create a new user group by typing groupadd NoPrivs. 25. Verify the new group by typing tail -3 /etc/group. 26. Change FileA.txt's group membership by typing chgrp NoPrivs FileA.txt. 27. Verify the change via the Is -I FileA.txt command. Note: The chgrp command changed the file's group, rather than add to its groups. 28. Clear the screen and type chown :root FileA.txt. Don't leave off the colon! 29 Recall Is -l FileA.txt. What group is the file in now? 30. Now, change both owner and group via a single command:chown root:NoPrivs FileA.txt. Note: The new owner comes before the colon and the new group comes after the colon. 31. Recall Is -I FileA.txt. Compare it to the previous listing. Did both the owner and group change? 32. Write and execute a command which changes the owner and group back to the original username. 33. What command did you use? 34. Verify the changes by listing the file in the long format 35. Make the regular user you logged into originally a member of the NoPrivs group: usermod -a -G NoPrivs username.. (Use your regular user's name instead of username) 36. Type groups username. Is your regular user now a member of the NoPrivs group? 37. Log out of the root account by typing exitJ. 38. As a standard user, try chgrp NoPrivs FileA.txt.. Was this successful? Note: This account's addition to the NoPrivs group will not take effect until they log in again. 39. Type exit to log out of the regular user account, then log back in on TTY2. 40. Use up arrow to recall the chgrp command, then list the file. Was it successful after logging back in? Notice that the system permits standard users to change the group on a file if they own the file AND are a member of that group. 41. Remove the file by typing rm -i FileA.txt. Type y when prompted. 42. What message do you now receive when trying to list the file? 43. Clear the screen and try to delete the group as a regular user: groupdel NoPrivs. Message? 44. Login as root using su - and try to delete the group using the same command. 45. Verify that the group has been removed: less /etc/group grep NoPrivs. 46. Type exit and press Enter to log out of the root account. Exploring File Permissions (Objective 5.4) 1. If necessary, boot up your MX Linux VM, launch virtual terminal 2, and log in as a regular user. 2. Type touch FileB.txt to create a blank empty file named FileB.txt. 3. List the new file in the long format, as you did in the first part of this lab. What command did you use? 4. Type chmod u+x FileB.txt. Translation: add (+) execute (x) permission to User (u) Note: "User" is the same as "owner" 5. Type Is - FileB.txt. Ref Figure 14.2. What is the owner's 3-character permission string now? 6. Change a Group permission: chmod g-r FileB.txt. Remove (-) read (r) permission from the group 7. Recall the list command. What is the group's 3-character permission string now? 8. Write a command which adds (+) write (w) permission to others (o) (everyone besides Owner & Group) 9. What command did you use? 10. Recall the list command. Ref Fig 14.2. What is World (others)'s 3-character permission string now? 11. To change multiple permissions simultaneously, type chmod ug=rw FileB.txtJ Translation: assign (=) read (r) & write (w) permissions only to user (u) & group (g) 12. Recall the list command. What are the user's and group's 3-character permission strings now? 13. In this step, you will change one permission for all three strings. Type chmod a+x FileB.txtJ Translation: add (+) execute (x) permission to all (a) 14. List the file. Was execute (x) permission added to all 3 groups? In the next step, you will change file permissions using the octal numbering system, which has only 8 symbols-0, 1, 2, 3, 4, 5, 6, and 7. (Our decimal numbering system has ten-0 through 9) From L to R, each 3 character set of permissions contains a 4's column, a 2's column, & a 1's column If read permission is set, there is a 1 in the 4's column. write is in the 2's column, execute in the 1's. If no permissions are enabled, the octal value = 0. If execute only is set, the value = 1. write only = 2, w + x = 3, read only = 4, r + x = 5, r + w = 6, r+w+x=7 Read (4) Write (2) Execute (1) See Table 14.2 15. Type chmod 000 FileB.txt Be sure to use zeroes, and not the letter o. 16. List the file. What are the permissions of all 3 groups? 17. Now type chmod 644 FileB.txt and pressing Enter. Translation: assign read + write permissions to user, read to group, and read to others 18. List the file. What are the permissions of all 3 groups? 19. Remove the file by typing rm -i FileB.txt. Type n when prompted. 20. Recall the command, remove the -i, and execute the command. 21. What was the purpose of the -i option in the rm command (use man rm if you like)?