Categories
Linux Tutorial Series

Linux Tutorial Series – 115 – File modes and permissions

Here is the video version, if you prefer it:

First of all, let’s talk about why are file modes and permissions important. Well, if you don’t have the right permissions, you might not be able to modify certain files (either read, write or execute them). That’s why sometimes you get the error saying “Permission denied”. That is exactly what happens – you don’t have the right permissions.

Every Linux file has a set of permissions that determine whether you have the rights to read, write or execute the file. (Ward, 2014)⁠ Let’s employ ls -l to find out permissions of a certain file:

mislav@mislavovo-racunalo:~/Linux_folder$ ls -l

total 36

-rw-r--r-- 1 mislav mislav 8 Feb 5 23:09 1264.txt

...

Let’s focus on the 1264.txt file. The permissions part is the following:

-rw-r--r--

Let’s break it down, looking from left to right:

  • - - this indicates the file type; - indicates a regular file, d indicates a directory and there’s some other file types as well (like links (l), which we will cover later; just know that they exist)
  • rw- – this indicates the user permissions – this file was created by the user mislav and this user can both read and write the file
  • r-- – this indicates the group permissions – this file belongs to a group called mislav (the 4th column in the ls -l output) and it can only read the file; it can’t write to it
  • r-- – this indicates the world permissions – the permissions of everyone else who is neither the user nor the group member

- means that that option is not supported and a letter in place of - means that that operation is supported. If in the last position x is used as a letter, that means that that the file is able to be executed.

A note on groups: If only you use your computer, you most likely won’t have to mangle with groups. Groups are sets of users – a convenient way to modify permissions for a set of users within a group (you can add users to groups and remove users from groups and change the group a file belongs to), but I never had to mangle with groups myself.

Hope you learned something useful!

References

Ward, B. (2014). How Linux Works: What Every Superuser Should Know (2nd ed.). No Starch Press. Pages 10; 33-34

NewsletterUpdates on interesting things I am doing

Subscribe to my newsletter to keep abreast of the interesting things I'm doing. I will send you the newsletter only when there is something interesting. This means 0% spam, 100% interesting content.

Leave a Reply

Your email address will not be published. Required fields are marked *