Sitemap

Linux — understanding permissions

2 min readOct 2, 2022

--

Press enter or click to view image in full size
Photo by Danielle Rice on Unsplash

This is a continuation of my article on Linux -users, and Groups.

The multi-user functionality of Linux is made possible by:
- creating users (covered in prev article)
- creating groups for the users (covered in prev article)
- creating permissions on files and directories.

Get Jamal Guyo’s stories in your inbox

Join Medium for free to get updates from this writer.

Let's look at an example before diving into how to create and remove permissions. If we list the contents of my home directory using the ls command (we covered this command in the Linux -basic Navigation article) we will get the following output:

jamal@jamal-hp:~$ ls -l
drwxrwxr-x 16 jamal jamal 4096 Jun 29 19:38 Desktop
-rw-rw-r-- 1 jamal jamal 0 Oct 2 15:38 demo.txt

This is what they mean:

  1. d — stands for a directory, in the case of a file you'll get a dash(-) instead. in the output above we can confirm that indeed Desktop is a directory and demo.txt is a file.
  2. rwx — the first set of three letters are Read, Write, Execute permissions relating to the user (the owner of that file/directory).
    - r — stands for read permission. The user can read the file/directory.
    - w — stands for write permission. The user can write to the file or directory.
    -x — stands for execute permission. The user can execute the file or the directory.
    if the user doesn't have the permission listed above, it is replaced with a dash(-).
  3. rwx — the second set of Read, Write, Execute permissions belong to the group the file or directory belongs to.
  4. rwx — the third set of Read, Write, Execute permissions belong to the other people who are neither the owners nor the group owning the file or directory.
  5. 16 — this is the number of links.
  6. jamal — this is the owner of the file/directory.
  7. jamal — this is the group of owners to which the file/directory belongs.
  8. 4096 — this is the size of the file/directory
  9. Jun 29 19:38 — this is the date and time the file/directory was created.
  10. Desktop — this is the name of the file/directory.

from the example,
- the
owner and the group of the directory desktop have the Read, Write and Execute permissions (rwxrwx)but the others only have Read and Execute permission(r-x) hence in full we have drwxrwxr-x (the d means this is a directory).
- the
owner and the group of the file demo.txt have the Read and write permissions(rw-rw-) but the others only have the Read permission (r- -) hence in full we have -rw-rw-r- -(the first dash (— )means this is a file not a directory).

NEXT → managing permissions in linux

--

--