# Understanding Linux File Permissions

Hey everyone in the last blog we've seen about the basic filesystem in the linux and some basics commands in this blog we will see more about permission and ownership of the linux system

Linux file permissions are a critical part of system security, allowing administrators and users to control who can read, write, or execute files. Let’s break down how these permissions work and how to modify them.

So what is permission exactly and what we are talking about now?

For example we take our smart phones

As the owner of the phone you have full access to your mobile like you can delete the files create the files updating the system etc simply you can do whatever you want since it was your

for the scenario lets say your friend ask your phone for one 30 mins, what we will do? for security purpose we will keep passwords to our phones and the applications inside in it so that your friend doesn't change anything without your knowledge

Same thing applies here

in Linux system the owner is root

root user can do any configuration related to the system

so what about the other users? how the system admin will change the files and how they configure the things ?

Lets say your friend wants to install one application so he will ask your permission can i install it ? and you say okay it doesn't affect anything to my phone go ahead

and you give your access to install it

In linux system as the normal user you don't have access to the entire system in that cases you will use the command called sudo

**sudo -&gt; Super User Do**

this command allows you to perform the action with the root access like changing the permissions to the files

CHMOD

You can change the permission of the file using the command called chmod

### Breaking Down the Permission Structure

When you view a file's details using `ls -l`, you’ll see something like:

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1730809923908/235ad801-57fc-4872-b330-49d43a09dd87.png align="center")

This line can be broken down as follows:

#### 1\. File Type

* **File Type**: The first character indicates the type of file:
    
    * `-` for a regular file
        
    * `d` for a directory
        
    * `l` for a symbolic link
        

#### 2\. Permissions

* **Permissions**: The next nine characters represent the permissions, divided into groups of three:
    
    * **First Set** (rwx): Permissions for the owner of the file.
        
    * **Second Set** (r-x): Permissions for the group that owns the file.
        
    * **Third Set** (r-x): Permissions for others (anyone else on the system).
        

**Example Breakdown**:

* The **owner** has read (`r`), write (`w`), and execute (`x`) permissions.
    
* The **group and others** has read (`r`) and execute (`x`) permissions.
    

---

### Changing Permissions with `chmod`

To modify permissions, you use the `chmod` command, which allows changes in either **symbolic** or **numeric** mode.

#### Symbolic Mode

In **symbolic mode**, you specify:

* **Who**: `u` (user/owner), `g` (group), `o` (others), or `a` (all).
    
* **Operation**: `+` (add), `-` (remove), `=` (set).
    
* **Permission**: `r` (read), `w` (write), or `x` (execute).
    

Example

Syntax  
  
chmod &lt;permission&gt; &lt;file name &gt;

Kindly please note below the other dont have access to write and excute the file

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1730810263040/48622087-cc1f-492e-bc36-d028dbe557a2.png align="center")

  
Now im going to give write and excute permissions to the other users  
  
for that im going to excute the command  
chmod o+wx file.txt  
  
now we will see the file below

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1730810349790/dbb0a096-4f8e-4190-9856-5d9251297818.png align="center")

#### Numeric Mode

In **numeric mode**, each permission is represented by a number:

* **Read (r) = 4**
    
* **Write (w) = 2**
    
* **Execute (x) = 1**
    

The sum of these values represents different permission levels:

* **7** (4+2+1) for read, write, execute
    
* **6** (4+2) for read and write
    
* **5** (4+1) for read and execute
    
* **4** for read-only
    

To set permissions, use a **three-digit number** where:

* The **first digit** is for the owner.
    
* The **second digit** is for the group.
    
* The **third digit** is for others.
    
    syntax for this mode is  
      
    chmod &lt;permission in numbers&gt; &lt;filename&gt;
    

By understanding these commands and concepts, you’ll have greater control over file security and permissions on a Linux system!
