From the last text I showed you how to enter data into a file. Sometimes the data you entered could be confidential. Then you don’t like accessing these data by others. Then what can we do to hide these data from the other users. LINUX has a great answer for this. That is file permission mechanism in LINUX.
WHAT IS FILE PERMISSION?
As I mentioned above using LINUX we can restrict others from accessing files in our system. We can give privileges to others to access our file and restrict some other user from accessing the file. There are three user groups in LINUX.
- Owner : He is the one who owns the file or who has created it.
- Group : The users of a particular group which the file has been assigned to.
- Others : The rest of the users of the system, who are not members of the group.
According to those user groups the owners can assign privileges to a a certain file or a directory. Also there are three permission types in LINUX too. The owner can give these permissions to each user group.
- r – read – Anyone who has the permission read, can view the file.
- w – write – Anyone who has the permission write, can add data to the file.
- x – execute – Anyone who has the permission execute, can execute the file.
According to the given permission a particular user can do what they are capable of with a particular file or a directory.
This is how the permissions are showed.
- The first letter ‘d’, refers that it is a directory. There could be some other letters as well,
- d – directory
- – – no special permission
- l – symbolic link (a reference to another file or a directory)
- Next three ‘rwx’, refers to owners permission regarding the particular file.
- Next three ‘rwx’, refers to group permission regarding the particular file.
- Next three ‘rwx’, refers to others permission regarding the particular file.
HOW TO CHANGE PERMISSION?
- chmod : This is the command used to change permissions. There are few parameters to know. After typing chmod, we should mention the user group to which we are going to change permission.
- u – owner
- g – group
- o – others
- a – all
- Then we should say whether we granting or revoking permission to that particular user group.
- + – Granting permission
- – – Revoking permission
- The next parameter for the permission type.
- r – Read
- w – Write
- x – Execute
- At last we can give name of the file or the directory.
In the above example I changed the reading permission of the Owner’s to the myViText file. Now even the owner won’t be able to read the file.
Again if we want to grant permission we can reenter the code with +r.
Now the Owner will be able to view the file.
From this text I tried to show how the file permission mechanism works in the LINUX Operating System. Hope you got some idea about how it works and how we can give permissions to different users for different tasks. See you soon with another interesting topic. Thank You!