bash-tutorial/tutorial/changeowner.org

49 lines
1.0 KiB
Org Mode
Raw Normal View History

2022-07-18 14:23:28 +02:00
#+options: toc:nil num:nil author:nil
* Changing permissions for files and directories
There are three types of permissions for files and directories in the system:
1. Read ('r')
2. Write ('w')
3. Execute ('x')
The permissions can be differente for users: owner - group - others
** Creating a file and checking permissions
Here we create a file with the sentence "this is a fancy file". The sentence is
redirected to the name "fancyfile.org" and a new file is created!
#+begin_src bash
echo "this is a fancy file" > fancyfile.org
#+end_src
#+RESULTS:
In the ouptut of ~ls~ command, there letters showing each permission for each user: owner, group, others, respectively.
#+begin_src bash
ls -la fancyfile.org
#+end_src
#+RESULTS:
: -rw-r--r-- 1 compartido compartido 21 jul 18 06:06 fancyfile.org
** Settings permissions for the file
#+begin_src bash
chmod o=r,g=rw,o=r fancyfile.org
#+end_src
#+RESULTS:
Then it changed!
#+begin_src bash
ls -la fancyfile.org
#+end_src
#+RESULTS:
: -rw-rw-r-- 1 compartido compartido 21 jul 18 06:06 fancyfile.org