Understanding Permissions On Linux
Tags: linux, computerscience, ubuntu, cybersecurity
Published: 2021-02-08 14:06:42

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.  
### File Type Field  
<mark>`-` </mark> 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. 
 
### Permissions Field  
-<mark>`rw-r--r--`</mark> 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:  
#### Owner  
<mark>`rw-`</mark>r--r--  
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.  

-rw-r--r-- 1 <mark>`admin`</mark> 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:  
#### Group  
-rw-<mark>`r--`</mark>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 <mark>`admin`</mark> 647 Dec 20  2017 hello.sh  
#### Other  
-rw-r--<mark>`r--`</mark> 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.  
### Permission Types  
here are three different permissions that can be placed on a file or directory: read, write, and execute.  
1. read(r)  
Allows for file contents to be read or copied.  
1. write(w)  
Allows for contents to be modified or overwritten. Allows for files to be added or removed from a directory.  
1. 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:  

Connect With me at [Twitter](https://twitter.com/larymak1) | [Insta](https://www.instagram.com/nextgencoders/) | [YouTube](https://www.youtube.com/channel/UCrT1ARRZfLOuf6nc_97eXEg) | [LinkedIn](https://www.linkedin.com/in/hillary-nyakundi-3a64b11ab/)  | [GitHub](https://github.com/larymak)

Do share your valuable opinion, I appreciate your honest feedback!  

Check out my other Blogs too:   
- [Administrative Access Commands On Linux](https://larymak.hashnode.dev/administrative-access-commands-on-linux) 
- [Why You Should Learn Linux](https://larymak.hashnode.dev/why-you-should-learn-linux-getting-set-for-linux)
- [Choosing The Right Python Framework for Web Development](https://larymak.hashnode.dev/choosing-the-right-python-framework-for-web-development)
- [How To Get Started With Open Source Project Contribution](https://larymak.hashnode.dev/how-to-get-started-with-open-source-project-contribution)
- [Build A Random Name Generator Using Python](https://larymak.hashnode.dev/build-a-random-name-generator-using-python)
- [How To Write A Good README File](https://larymak.hashnode.dev/how-to-write-a-good-readme-file)
- [Top Freelancing Tool For Developers](https://larymak.hashnode.dev/top-freelancing-tools-early-2021)
- [Top Apps To Learn Coding](https://larymak.hashnode.dev/top-apps-to-learn-coding)
- [Coding A Jokes App Using Python](https://larymak.hashnode.dev/coding-a-comicjokes-app-using-python)


See you in my next Blog article, Be Safe and Take care!!  
Enjoy Coding