Permissions determine the ways different users can interact with a file or directory. When listing a file with the
ls -l command, the output includes permission information. For example if we will want to use a script file called hello.sh located in the Documents directory :
First we will have to switch into the Documents Directory using this example below for instance:
admin@localhost:~$ cd ~/Documents
Now since we are in the Documents directory we will have to use the
ls -l to view the permissions, the output will be something like the below example:
admin@localhost:~/Documents$ ls -l hello.sh -rw-r--r-- 1 admin admin 647 Dec 20 2017 hello.sh
Now below we will look at a review of the fields relevant to permissions.
- rw-r--r-- 1 admin admin 647 Dec 20 2017 hello.sh
The first character of this output indicates the type of a file.
if the first character is a
-, this is a regular file. If the character was a
d, it would be a directory.
rw-r--r-- 1 admin admin 647 Dec 20 2017 hello.sh
After the file type character, the permissions are displayed. The permissions are broken into three sets of three characters:
The first set is for the user who owns the file. If your current account is the user owner of the file, then the first set of the three permissions will apply and the other permissions have no effect.
admin admin 647 Dec 20 2017 hello.sh
The user who owns the file, and who these permissions apply to, can be determined by the user owner field:
r--r-- 1 admin admin 647 Dec 20 2017 hello.sh
The second set is for the group that owns the file. If your current account is not the user owner of the file and you are a member of the group that owns the file, then the group permissions will apply and the other permissions have no effect.
The group for this file can be determined by the group owner field:
-rw-r--r-- 1 admin
admin 647 Dec 20 2017 hello.sh
r-- 1 admin admin 647 Dec 20 2017 hello.sh
The last set is for everyone else, any one who that first two sets of permissions do not apply to. If you are not the user who owns the file or a member of the group that owns the file, the third set of permissions applies to you.
here are three different permissions that can be placed on a file or directory: read, write, and execute.
- read(r) Allows for file contents to be read or copied.
- write(w) Allows for contents to be modified or overwritten. Allows for files to be added or removed from a directory.
- execute(x) Allows for a file to be run as a process, although script files require read permission, as well. > Understanding which permissions apply is an important skill set in Linux
If You have read this far I really appreciate, Help me to grow my community:
Do share your valuable opinion, I appreciate your honest feedback!
Check out my other Blogs too:
- Administrative Access Commands On Linux
- Why You Should Learn Linux
- Choosing The Right Python Framework for Web Development
- How To Get Started With Open Source Project Contribution
- Build A Random Name Generator Using Python
- How To Write A Good README File
- Top Freelancing Tool For Developers
- Top Apps To Learn Coding
- Coding A Jokes App Using Python
See you in my next Blog article, Be Safe and Take care!!