In the Linux file system, there are 3 types of users and the owner can give permissions to these user types. These users are owners, groups, and others.
๐๐ฐ๐ง๐๐ซ๐ฌ๐ก๐ข๐ฉ
Owner: the owner is the user who created the file or directory
Group: a group can have multiple users. All users in the group have the same permissions to access the file or directory
Other: other means those who are not owners or members of the group
The file permissions a user can have is:
R โ Read ๐ W โ Write ๐ X โ Execute โ
Read โ User can read the contents Write โ User can modify content Execute โ User has permission to execute files
As an example, I used the 'cd' command to move to my documents. Then I used 'ls -l' to list the files I have. Doing this will show the permissions of either the file or directory.
Here is an example of what permissions would look like:
By this command, we have listed down all the files and directories inside the current directory. Files start with a "-" dash while directories start with "d" in the beginning.
info.txt file has permissions rw-r--r--
Divide this permission into groups of 3. Users, groups and others have permissions rw-, r-- & r-- respectively. The owner has permission to read & write the file. While groups and others have permission to only read the file. We can change the permissions as well with chmod command
chmod options permissions file name
This permission can be set numerically as well as by alphabetical short forms of permissions -
chmod 765 info.txt
This will change permission to 111 110 101 in binary form, and compare it with 110 100 100 earlier permissions. You can see we have added execute permission for the owner, write and execute for the group and execute for others.
Now let's reset the permission and again set them to 765 by a different method.
run chmod 644 info.txt
then run
chmod u+x info.txt
chmod g+w info.txt
chmod o+x info.txt
this is similar to chmod 765 info.txt in effect.