What are permissions in Linux OS? Every file or folder in Linux has access permissions.This permissions will define what we can do with the files.
There are three types of permissions:
Permissions are defined for three types of users:
To see the permission of a file we can use the following command :
will list all the objects in the current working directory
We can see in the above image that we have 3 objects in our /Documents dir.
File permissions notation
Now let's learn how to interpret all the crazy numbers and words and the other stuff on the terminal after the use the "ls -l" command.
Since we are at the terminal line and we do not have any graphical and we can not click+right to see our file proprieties we need to learn how to interpret out terminal information.
Textual representation
Is represented by 10 characters.
These permissions can be divided up as follows:
Position 1 and it's possible types:
Positions 2, 3 and 4 tell us if the owner has read, write and execute permissions for the file or object.
So if we have for example this situation :
We can see in the above image that we have 3 objects in our /Documents dir.
Let's "translate" each of them :
So how do we interpret this ?
Type
We can see the object is a Directory.
Permissions
Links
- we have 2 links to this dir.
Owner
- the owner of this dir is "wannabedba";
Group
- the group that "wannabedba" is part of is "wannabedba";
Size
- the size of the file is 4.0 k or 4096 , if the dir has less then 4.0 k then it will show the minimum size of a block.(which is 4096);
Data of creation/modified
- we can see that this dir was created on 2012-03-29;
Time of creation/modified
- this dir was created/modified at 17:35;
Name
- the name of our dir is "dir1";
How to give and change permissions in Linux.
For this task we will need to use the "Chmod" command.
Syntax of the chmod command is:
Options
Numeric Permissions:
CHMOD can be attributed by using Numeric Permissions:
Syntax
This gives the file read/write by the owner and only read by everyone else(-rw-r--r--).
Here is shown how the octane and how they be used with "chmod":
First thing you need to know is that there are 10 bits associated with every file sliced in 4 parts (type,owner,group,guests) like we have learned at the begging of this tutorial. We will take an example of a file and show how permissions are represented in octal number, so we can apply them when we give permissions to our file,dirs.
The existing permissions for the above file in octal numbers could be represented as follows
Frequently used numeric parameters for chmod.
In the next tutorial we will learn how to create new objects(files,dir,etc..) in Linux OS.