From fc70fcde1f621bd65baa943288f0e6a2624e3da6 Mon Sep 17 00:00:00 2001 From: Jose Date: Sat, 8 Apr 2023 17:20:56 -0300 Subject: [PATCH] Fixing typos --- tutorial/changeowner.org | 67 ++++++++++++++++++++++++++-------------- 1 file changed, 43 insertions(+), 24 deletions(-) diff --git a/tutorial/changeowner.org b/tutorial/changeowner.org index e1daf74..ee8fc2b 100644 --- a/tutorial/changeowner.org +++ b/tutorial/changeowner.org @@ -4,11 +4,18 @@ There are three types of permissions for files and directories in the system: -1. Read ('r') -2. Write ('w') -3. Execute ('x') +| Permission | Files | Directories | +|---------------+-----------------+-------------------| +| Read ('r') | Read the file | List contents | +| Write ('w') | Change the file | Create amd remove | +| Execute ('x') | Execute files | Access the files | -The permissions can be differente for users: owner - group - others + +Permissions can be differente for different users: + +- Owner of the files +- Group: other users in the file's group +- Others ** Creating a file and checking permissions @@ -28,12 +35,20 @@ In the ouptut of ~ls~ command, there letters showing each permission for each us #+end_src #+RESULTS: -: -rw-r--r-- 1 compartido compartido 21 jul 18 06:06 fancyfile.org +: -rw-r--r-- 1 user user 21 jul 18 06:06 fancyfile.org ** Settings permissions for the file +Setting permissions for the + +- User who owns the file = "u" +- Other users in the group = "g" +- Other users = o + +You may change the permissions for each user, using letters (r-w-x): + #+begin_src bash - chmod o=r,g=rw,o=r fancyfile.org + chmod u=r, g=rw, o=r fancyfile.org #+end_src #+RESULTS: @@ -45,7 +60,7 @@ Then it changed! #+end_src #+RESULTS: -: -rw-rw-r-- 1 compa user 21 jul 18 06:06 fancyfile.org +: -r--rw-r-- 1 user user 21 jul 18 06:06 fancyfile.org ** Changing permission for directories @@ -56,7 +71,6 @@ contains multiple subdirectories. Let's call that directory "buds" I can't access the files without being `root`. This is the outuput in the command line When a list the directory using `ls -la`. - #+begin_example bash drw-r--r-- 81 user user 4096 dec 26 06:21 buds #+end_example @@ -70,29 +84,25 @@ every file within the directory: new mode 100755 #+end_example +Thus, the directory has the following permissions -This is how the permission could be changed: - -Note that, in this case, it's necessary to use `sudo` before the command to -access the files - -#+begin_src bash - chmod -R o=wxr,g=xr, o=x buds -#+end_src - -This will change the permissions for: +- For the owner = read (4) and write (2) +- For the group = read (4) +- For others = read (4) + +Using ~chmod~ 744 will change the permissions for: * The owner (4 = read; 2 = write; 1 = execute) - * The group (4 = read) and + * The group (4 = read) and * Others (4 = read) -Use ~-R~ if you want to apply recursive ~chmod~ +Applying the same logic to a file: #+begin_src bash chmod 744 NameOfFileHere #+end_src -Think of the following code: what does that code do? +Use ~-R~ if you want to apply recursive ~chmod~ #+begin_src bash chmod -R 755 NameOfFileHere @@ -101,16 +111,20 @@ Think of the following code: what does that code do? *** The output now is: #+begin_example bash - drw-r-x--x 81 user user 4096 dec 26 06:21 buds + drwxr-xr-x 81 user user 4096 dec 26 06:21 buds #+end_example -Remember how it looks before +Remember how it was before #+begin_example bash drw-r--r-- 81 user user 4096 dec 26 06:21 buds_before #+end_example -But I still can open the files. That is because need to change the owner: +** Changing owner + +But I still can open the files. That is because need to change the owner. + +To change the owner of files the command ~chown~ may be used #+begin_example bash chown NameOfownerHere buds # Try this and check the result @@ -125,3 +139,8 @@ Include the owner then ~:~ and then the name of the group to change ownership fo ps: should use`sudo` to run this command, so be careful and make a scratch directory to run tests. + +** References + +- Check the manual: info -> Coreutils -> File permissions. In bash: ~info coreutils~ + Coreutils are standard programs for text and file manipulation