diff options
| -rw-r--r-- | README.md | 25 | ||||
| -rw-r--r-- | exercises/chapter-8.14 | 31 | ||||
| -rw-r--r-- | exercises/chapter-8.15 | 15 |
3 files changed, 57 insertions, 14 deletions
@@ -304,12 +304,12 @@ The `umask` indicates which permission bits to turn off. ie. `777 - mask`. To change the default umask to `037`. ```bash -$ touch before +$ mkdir -p before $ umask 037 -$ umask after +$ mkdir -p after $ ls -alh before after --rw-r-----. 1 root root 0 May 25 19:03 after --rw-r--r--. 1 root root 0 May 25 19:03 before +drwxr-----. 2 root root 4.0K May 25 19:31 after +drwxr-xr-x. 2 root root 4.0K May 25 19:31 before ``` The default access privileges are: @@ -334,6 +334,23 @@ See `exercises/chapter-8.14`. 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? +I can use the `umask` builtin to set the default access privileges. I +can test this by creating a file before the change and then creating a +file after the change. Then I can list the permissions for both the +before and after files to witness the difference. I can also run `umask` +to see what the current setting is. + +To change the default access privileges to `rwx|r-x|---` (750) I can use the +formula: + +```text +777 - 750 = 027 +``` + +The desired `umask` value would be `027`. + +See `exercises/chapter-8.15`. + 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? diff --git a/exercises/chapter-8.14 b/exercises/chapter-8.14 index 172cfdd..582a8a1 100644 --- a/exercises/chapter-8.14 +++ b/exercises/chapter-8.14 @@ -1,15 +1,26 @@ -Script started on 2019-05-25 13:08:45-06:00 [TERM="screen-256color" TTY="/dev/pts/7" COLUMNS="238" LINES="13"] +Script started on 2019-05-25 13:31:17-06:00 [TERM="screen-256color" TTY="/dev/pts/7" COLUMNS="238" LINES="13"] bash-5.0$ docker run -it fedora /bin/bash
-]0;@d8fb6f3d47d3:/[root@d8fb6f3d47d3 /]#
[K[root@d8fb6f3d47d3 /]# cd
-]0;@d8fb6f3d47d3:~[root@d8fb6f3d47d3 ~]# touch before
-]0;@d8fb6f3d47d3:~[root@d8fb6f3d47d3 ~]# umask 037
-]0;@d8fb6f3d47d3:~[root@d8fb6f3d47d3 ~]# touch after
-]0;@d8fb6f3d47d3:~[root@d8fb6f3d47d3 ~]# ls -alh before after
--rw-r-----. 1 root root 0 May 25 19:09 after
--rw-r--r--. 1 root root 0 May 25 19:08 before
-]0;@d8fb6f3d47d3:~[root@d8fb6f3d47d3 ~]# exit
+]0;@129dafd2e4c3:/[root@129dafd2e4c3 /]#
[K[root@129dafd2e4c3 /]# cd
+]0;@129dafd2e4c3:~[root@129dafd2e4c3 ~]# mkdir -p before
+]0;@129dafd2e4c3:~[root@129dafd2e4c3 ~]# umask 037
+]0;@129dafd2e4c3:~[root@129dafd2e4c3 ~]# mkdir -p after
+]0;@129dafd2e4c3:~[root@129dafd2e4c3 ~]# ls -alh
+total 64K
+dr-xr-x---. 1 root root 4.0K May 25 19:31 [0m[01;34m.[0m
+drwxr-xr-x. 1 root root 4.0K May 25 19:31 [01;34m..[0m
+drwxr-----. 2 root root 4.0K May 25 19:31 [01;34mafter[0m
+-rw-------. 1 root root 3.4K Mar 7 06:48 anaconda-ks.cfg
+-rw-r--r--. 1 root root 508 Mar 7 06:48 anaconda-post.log
+-rw-r--r--. 1 root root 18 Jul 15 2018 .bash_logout
+-rw-r--r--. 1 root root 176 Jul 15 2018 .bash_profile
+-rw-r--r--. 1 root root 176 Jul 15 2018 .bashrc
+drwxr-xr-x. 2 root root 4.0K May 25 19:31 [01;34mbefore[0m
+-rw-r--r--. 1 root root 100 Jul 15 2018 .cshrc
+-rw-------. 1 root root 3.1K Mar 7 06:48 original-ks.cfg
+-rw-r--r--. 1 root root 129 Jul 15 2018 .tcshrc
+]0;@129dafd2e4c3:~[root@129dafd2e4c3 ~]# exit
exit
bash-5.0$ exit
exit
-Script done on 2019-05-25 13:09:08-06:00 [COMMAND_EXIT_CODE="0"] +Script done on 2019-05-25 13:32:00-06:00 [COMMAND_EXIT_CODE="0"] diff --git a/exercises/chapter-8.15 b/exercises/chapter-8.15 new file mode 100644 index 0000000..78bdc8a --- /dev/null +++ b/exercises/chapter-8.15 @@ -0,0 +1,15 @@ +Script started on 2019-05-25 13:13:49-06:00 [TERM="screen-256color" TTY="/dev/pts/7" COLUMNS="238" LINES="13"] +bash-5.0$ docker run -it fedora /bin/bash
+]0;@777f2d53e3df:/[root@777f2d53e3df /]#
[K[root@777f2d53e3df /]# cd
+]0;@777f2d53e3df:~[root@777f2d53e3df ~]# touch before
+]0;@777f2d53e3df:~[root@777f2d53e3df ~]# umask 027
+]0;@777f2d53e3df:~[root@777f2d53e3df ~]# touch after
+]0;@777f2d53e3df:~[root@777f2d53e3df ~]# ls -alh before after
+-rw-r-----. 1 root root 0 May 25 19:14 after
+-rw-r--r--. 1 root root 0 May 25 19:14 before
+]0;@777f2d53e3df:~[root@777f2d53e3df ~]# exit
+exit
+bash-5.0$ exit
+exit
+ +Script done on 2019-05-25 13:14:32-06:00 [COMMAND_EXIT_CODE="0"] |
