Basic File Permissions
Linux systems in general break file permissions into three basic types:
- Read
- Write
- Execute
These basic types tie into the ownership of the file. The owners are broken down into three groups as well:
- Owner
- Group
- Other
These permissions and ownerships are represented as a three digit number. Each digit can have a value of 0-7 (inclusive). first digit represents owner permissions, the second digit represents group permissions, and the last digit is for others. There is a number associated with each permission where read has a value of 4, write has a value of 2, and execute has a value of 1.
When we look at the binary values for these permissions it all makes sense:
Read: (4)d = (100)b
Write: (2)d = (010)b
Execute: (1)d = (001)b
----------------------
All: (7)d = (111)b
because of this design we can easily find/set permissions for any file in linux.
For example a file that has all permissions for Owner, but no permissions for group or others will have a permission of 700.
Changing permissions on a file in Linux
To change the permissions of a file we use a utility called chmod. chmod stands for Change Mode. This is a utility that is shipped with many linux distributions. Since chmod is changing permissions on a file (writing new permissions) then you need to have write access to the file that you are trying to change.
so the code looks like something like this: sudo chmod 777 file_name
Changing ownership of a file in linux
To change the ownership of a file we use a utility called chown which stands for change owner the syntax for this is as follows:
sudo chown user:user_group file_name
If you have any questions or there is something incorrect here please let me know and I will fix it.
Top comments (0)