# Day 6 - Task: File Permissions and Access Control Lists (Dec 2, 2023)

### Today is more on Reading, Learning and Implementing File permissions

The concept of Linux File permission and ownership is important in Linux. Here, we will be working on Linux permissions and ownership and will do tasks on both of them. Let us start with the Permissions.

1. Create a simple file and do `ls -ltr` to see the details of the files [refer to Notes](https://github.com/LondheShubham153/90DaysOfDevOps/tree/master/2023/day6/notes)
    

Each of the three permissions are assigned to three defined categories of users. The categories are:

* ```plaintext
       owner   —   The owner of the file or  application.
    ```
    
* "chown" is used to change the ownership permission of a file or directory.
    
* ```plaintext
       group   —   The group that owns the file or application.
    ```
    
* "chgrp" is used to change the group permission of a file or directory.
    
* ```plaintext
       others  —   All users with access to the system. (outised the users are in a group)
    ```
    
* "chmod" is used to change the other users permissions of a file or directory.
    
    As a task, change the user permissions of the file and note the changes after `ls -ltr`
    

1. Write an article about File Permissions based on your understanding from the notes.
    
2. Read about ACL and try out the commands `getfacl` and `setfacl`
    

Welcome back to our Linux learning journey! Today's focus is on delving into the intricacies of file permissions and exploring the powerful world of Access Control Lists (ACL). So, let's roll up our sleeves, fire up our terminals, and dive right in!

## **Understanding Linux File Permissions**

In the Linux world, managing file permissions is a crucial aspect of ensuring the security and integrity of your system. Every file and directory comes with a set of permissions that dictate who can read, write, or execute them. There are three main categories of users, each with its own set of permissions:

1. **Owner:** This is the user who owns the file or application. You can change ownership using the `chown` command.
    
2. **Group:** Every file belongs to a specific group, and you can modify this using the `chgrp` command.
    
3. **Others:** This category includes all users with access to the system, excluding the owner and group members. You can tweak their permissions with the `chmod` command.
    

### **Task: Changing User Permissions**

Let's start by creating a simple file and observing its permissions:

```plaintext
$ touch sample_file
$ ls -ltr
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1701685811067/813983bc-ed22-4048-8815-9d3dc766c344.png align="left")

This will display the details of the file, including its permissions. Now, as a task, let's change the user permissions using the `chmod` command and see how it reflects in the `ls -ltr` output.

```plaintext
$ chmod u+rwx sample_file
$ ls -ltr
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1701685864966/9d27e148-212e-47a8-89cb-b01212923933.png align="center")

Observe the changes in the permissions and take note of how the user permissions have been modified.

## **Article: The Dance of Permissions**

File permissions in Linux are like the gatekeepers of your digital kingdom. They determine who gets to enter, who can read the scrolls, and who can rewrite history. Let's break down the key components:

### **1\. The Trio of Permissions**

#### a. Read (r)

The read permission allows a user to view the content of a file or list the contents of a directory.

#### b. Write (w)

The write permission empowers a user to modify the file's content or add, remove, and rename files within a directory.

#### c. Execute (x)

Execute permission is necessary to run a file as a program or script. For directories, it allows users to traverse the directory.

### **2\. Ownership Matters**

Changing ownership with `chown` is like passing the scepter to a new ruler. It's a powerful command that ensures the right person holds the reins.

### **3\. Group Dynamics**

Files don't exist in isolation; they belong to groups. Modifying group ownership via `chgrp` is like reshuffling your council – important for collaborative projects.

### **4\. Other Users in the Realm**

`chmod` is the maestro conducting the symphony of permissions for others. It decides what outsiders can and cannot do.

Remember, the magical trio of read, write, and execute applies to each category – owner, group, and others – granting or restricting access accordingly.

## **Venturing into ACL**

Access Control Lists (ACL) take file permissions to the next level. They allow for fine-grained control, enabling you to specify permissions for specific users or groups. Try out the following commands:

```plaintext
$ getfacl sample_file
$ setfacl -m u:username:rw sample_file
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1701685788201/34154382-f1bd-41e3-89a8-4667cd6975ac.png align="left")

This snippet uses `getfacl` to display the ACL of `sample_file` and `setfacl` to grant read and write permissions to a specific user. Explore these commands to enhance your control over file access.

### **Seeking Clarifications**

Learning is a journey, and doubts are the stepping stones to understanding. If you encounter any roadblocks, feel free to share your queries on our Discord community. The community is a vibrant space where fellow learners and mentors collaborate, troubleshoot, and celebrate victories together.
