Know your Linux 03: Permissions
Bassem
Posted on August 11, 2019
Hello and welcome to another entry in “Know your Linux” series. This time let’s talk about Linux’s permissions. Should we dive right in? 🏄♂️
Before we do ✋ Make sure to check out the second entry in the series.
Article No Longer Available
Users categories :
Each file in Linux has 3 categories of users to which permissions apply to.
- User: The file’s owner user, normally that is the user that created the file. 2.Group: All of the users that are members of the file’s owner group, normally that is the primary group of the owner user. 3.Others: All other users on the system that are not the owner user and are not members of the owner group.
Types of permissions :
Each user category can have 3 types of permissions. Those permissions could mean different things depending on whether they are applied to a file or a directory.
- Read (r): On a file, It means that the file’s content could be read. On a directory, It means that the directory’s content could be listed.
- Write (w): On a file, It means that the file’s content could be changed. On a directory, It means that you can create or delete any file inside this directory.
- Execute (x): On a file, It means that the file could be executed. On a directory, It means that the directory’s content can be accessed.
There are some other special permissions that I won’t be covering today. For now, that's all! Yeah!! 🎉, it is that simple. That's all you need to know when it comes to Linux’s file permissions. Want to see an example? 🤔
Let’s see it in action :
Running the ls -l command which is a list directory contents command with -l option for the long listing format, provides much more info about each file.
Each line is a file or a directory. You can see its name in the last column. But what are those first 4 columns?
- The first column “-rwr—r—“ is the actual permissions for that file. We will be discussing it in a minute.
- The second column is the number of hard links each file have. This is irrelevant to today’s topic.
- The third column is the name of the file’s owner user.
- The fourth column is the name of the file’s owner group.
As you can tell by the image above. The index.php file is owned by the user www-data and its owner group is www-data.
The www-data user is not an actual human user, This is a user created for and used by the webserver process. It is used to limit the server’s access and permissions. In Linux, every service must have a user to run under.
Now let's discuss the first column in detail. As you can see here “-rwxrwxrwx”. This string is actually composed of 4 substrings.
- The first bit determines the file type “-“ for a hard link (file), “d” is for a directory and “l” is a soft link (shortcut)
- The next 3 bits determine the permissions for the owner user, “rwx” means that he has all permissions.
- The next 3 bits determine the permissions for the owner group, again “r-x” means that everyone in that group has read, execute but not write.
- The next 3 bits determine the permissions for every other user that is not the owner user or is not in the owner group, “r—” means that he has read but not write or execute.
That’s all from my side. ✋
If you enjoyed the post, please let me know and check out the next entry. 🙄
Article No Longer Available
As always,
Happy coding 🔥🔥
“كود بسعادة”
Posted on August 11, 2019
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
November 28, 2024
November 29, 2024