- 0.1 File Permissions in Linux using Chmod
- 0.2 Types of Classes in Chmod
- 0.3 Chmod Number assignment
- 0.4 Setting File Permissions in Command Line
- 1 chmod command uses & Explanation
chmod command is one of the useful commands in user and file management (specially script files). Here we are going to explain you chmod 775 , 755 & File permissions
File Permissions in Linux using Chmod
As you know the file system of linux has a file access and control mechanism which determines how and who can access a file stored in a linux system. This mechanism is based on two parts i.e. namely Classes and Permissions.
Classes determines who can access the files while Permissions decides how the file can be accessed to the user.
Hire An App Developer from here
Types of Classes in Chmod
Three types of classes exits in linux i.e. Owner, Group, Others.
- The owner is the creator of files / folder in linux. By default all the file and folders you create are owned by you, until you change the permissions manually.
- The Group consists of multiple users who share same permissions and user privilege.
- Others means the general public.
Permission Types in Linux
Next is permission , which are of three types based on a file or Folder, which you can either read, write or execute.
- Read :- One can read a file but they can’t modify the contents. In case of Folder , you can see the files inside Folder, but you can’t delete or add files into folder.
- Write :- Here you can modify file contents & in Folder you can delete and add files into the folder.
- Execute :- This permission allows one to run a file (mainly script).
If you combine the use of class and permission , you can control users on how they can access a file and what actions they can do or what they should not.
This can be understood by an example i.e. Owner has all the permissions (read, write and execute) to access a file. So if aren’t the owner of file /folder then you have to change the permissions to get the owner access to the file. The ownership of a file can be changed to any user as per requirements. The web server may won’t allow you to upload a file , in this case you are not having the enough permissions to add a file in a folder.
Chmod Number assignment
Now I expect you got the basic concept of classes and permissions , so we can go forward to the number i.e. “775” & “777”.
The file and folder is having a 8-bit data that controls the permissions mechanism. The basic binary form is “000” which means no permissions to any form.
- As you set the “Read” permission , it adds 4-bit data which makes it “100” or a 4 in the usual decimal format.
- Granting a write permission adds 2 bit data i.e “010” or 2 in decimal form.
- Adding a “Execute” permission adds 1-bit to the data, which will result in “001”, or “1” in decimal form.
Numbers assigned to Read , Write & Execute
In other words
- Read is equivalent to ‘4’.
- Write is equivalent to ‘2’.
- Execute is equivalent to ‘1’
So as u decide to set permissions , we have to add the numbers. For example if we set permissions to read and write , then its like 6 (4 + 2) for the permission. For read, write and execute, we will use ‘7’ (4 + 2 + 1) for the permission. Here’s the different permutation:
Chmod All Combinations
- 0 – no permission
- 1 – execute
- 2 – write
- 3 – write and execute
- 4 – read
- 5 – read and execute
- 6 – read and write
- 7 – read, write, and execute
Using the numbers you can grant permissions to a file and add the numbers accordingly. So just understand this the three digits are “777”. First digit is for Owner, second or Group and third digit is for Others. If you assign “777” for a user then you can give all permissions for a file to all users.
|String||Permissions it provide|
|755||It is used in web server. The owner of file has all the permissions but all two i.e. Group and Others have permission to read and execute,they can’t make changes to the file.|
|777||This number provides all the permissions of file to all three types of users. Every user can read , write and execute the file. It allows the users to add any type of code to your file. This is mainly applicable to the images in a website.|
|644||The owner can read and write while every other can only read it. No other can execute the file too.|
|655||The owner can read and write but can’t execute the file. Everyone except owner can read and execute but they can’t modify the file.|
Setting File Permissions in Command Line
Linux lets you set all the file permissions by right click on the folder and by selecting “Properties”. The permission tab will let you assign permissions to the Owner , Group & Others.
The other way is terminal , where you can change the permission via Chmod. If you use chmod 777 that means you assigned all the permissions i.e. to make file readable, writable and executable by everyone.
Hope the article helps you to understand the concept of permissions in a Linux system and the meaning of “777” & “775”.