From 40972a4d19c74b8fa0c751eed20a25e0f67ab7e8 Mon Sep 17 00:00:00 2001 From: mokha Date: Sat, 18 May 2019 16:30:20 -0600 Subject: complete next exercise --- README.md | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/README.md b/README.md index 01db593..be2e9c0 100644 --- a/README.md +++ b/README.md @@ -118,6 +118,53 @@ chapter9.eps: empty 2. Solve problems 7–17 at the end of Chapter 8. +7. How do the read, write, and execute permissions work in UNIX? Illustrate your answer with some examples. + +Permission bits are organized as follows: + +| type | Read | Write | Execute | Read | Write | Execute | Read | Write | Execute | + +* The first bit indicates if the file is a directory or has the `setuid` bit enabled. +* The following 3 bits represent the read, write, execute permissions for the user. +* The following 3 bits represent the read, write, execute permissions for the group. +* The following 3 bits represent the read, write, execute permissions for everyone else. + +E.g + +```bash +モ ls -alh README.md +-rw-r--r-- 1 mokha staff 7.8K 18 May 16:20 README.md +``` +The `-` indicates a file. +The `rw-` indicates read and write permissions for the owner of the file. +The following `r--` indicate read permissions for members of the group. +THe following `r--` indicate read permissions for everyone else. + +8. How many user groups exist on your system? How did you get your answer? What groups are you a member of and what is your default group? How many groups is root a member of, on your system? How did you obtain your answer? If used any commands, show the commands and their outputs. +9. Create a file test1 in your present working directory and set its access privileges to read and write for yourself, read for the users in your group, and none to everyone else. What command did you use to set privileges? Give another command that would accomplish the same thing. +10. The user ‘sarwar’ sets access permissions to his home directory by using the command chmod 700 $HOME. If the file cp.new in his home directory has read permissions to 777, can anyone read this file? Why or why not? Explain your answer. +11. What is the effect of each command? Explain your answers. +a. chmod 776 ∼/lab5 +b. chmod 751 ∼/lab? +c. chmod 511 *.c +d. chmod 711 ∼/* +e. ls -l +f. ls -ld +g. ls -l ∼/personal +h. ls -ld ∼/personal +12. What does the execute permission mean for a directory, a file type for which the execute operation makes no sense? +13. Create a file dir1 in your home directory and use cp /etc/passwd dir1/mypasswd command to copy the /etc/passwd file in it. Use the chmod command to have only the search permission on for it and execute the following commands. What is the results of executing these commands? Do the results make sense to you? Explain. +a. cd dir1 +b. ls +c. rm dir1/mypasswd +d. cp /etc/passwd dir1 +14. What umask command should be executed to set the permissions bit mask to 037? With this mask, what default access privileges are associated with any new file that you create on the system? Why? Where would you put this command so that every time you log on to the system this mask is effective? +15. Give a command line for setting the default access mode so that you have read, write, and execute privileges, your group has read and execute permissions, and all others have no permission for a newly created executable file or directory. How would you test it to be sure that it works correctly? +16. Give chmod command lines that perform the same tasks that the mesg n and mesg y commands do. (Hint: Every hardware device, including your terminal, has an associated file in the /dev directory.) +17. What are the purposes of the set-user-ID (SUID), set-group-ID (SGID), and sticky bits? + + + -- cgit v1.2.3