When learning Linux, sometimes people have a tough time understanding how folder/file/application permissions work. I am writing this to show you a quick easy way to figure out which permissions to use.
Folder/file permissions on Linux can be difficult to understand. Sometimes you will see 0775 or 735 or if you are looking at files in Linux (using ll or similar command) you will see something like -rw-rw-r--.
Figuring out what these mean is easy, you just need to perform two steps and you can have permissions the way you want in no time. Also, keep in mind that the 0775 is basically the same as 735, the leading zero on the second has been removed and is not displayed in this report. For the purposes of this post, we are going to ignore the leading zero. Let's look real quick how 0775 (or 735) and the display of "-rw-rw-r--" relate.
Understanding how we got the 7
The second number of 0775 is actually made of from this simple chart by adding which permissions you want enabled:
4 : Read
2 : Write
1 : Execute
0 : None
These four options are compined in various ways to give you exactly the permission you want for each digit in the full sequence of 0775. The second number has all the permissions ( 4+ 2 + 1 = 7) meaning it can be read, written, and executed (if executable). Like wise, setting this to read and write only, would equal the number 6.
So, now understand the full sequence as it applied to the file/folder/application
The numbers representing the our demo sequence of 0775 have been charted to show what each one represents.
0 : Reserved (we not discussed this in this tutorial)
7 : User (the permissions of the user)
7 : Group (groups made in Linux, this could be staff, etc.)
5 : World (the permissions the rest of the world [or in our case, operating system users/guests])
Now let's look at how 0775 and -rw-rw-r-- relate
You may have already guessed it, but here it goes. You will notice there are 3 main permissions (read, write, execute). The first letter in the sequence -rw-rw-r-- is that one that we don't talk about in this tutorial, the leading zero in 0775. The next three letters or hyphens (rw-), make up the read, write, and execute permissions for the user group. The following 3 after that make up the permissions for the Group. And the last 3 represent the world permissions.
Now you hopefully have an idea of how to read, understand, and how to set up your own permissions.
At the time of writing this, I am new to some things Linux and am bound to get things wrong. If I have listed something incorrectly, please let me know so I can change it and provide good reliable information. Thanks.