> For the complete documentation index, see [llms.txt](https://cybersecurity-cloud-and-it-notes.gitbook.io/kyles-cybersecurity-cloud-and-it-gitbook/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cybersecurity-cloud-and-it-notes.gitbook.io/kyles-cybersecurity-cloud-and-it-gitbook/google-cybersecurity-professional-cert/4.-linux-and-sql-tool-of-the-trade/module-3/authenticate-and-authorize-new-users/permission-commands.md).

# Permission commands

#### 🎉 Fun & ADHD-Friendly Notes on Permission Commands in Linux 🎉

**Let’s dive into the magical world of Linux permissions! 🌍**\
In this lesson, we’ll break down how to **read**, **change**, and **manage** file and directory permissions like a pro!

***

#### 🚦 **What Are Permissions?** 🚦

Permissions control **who** can do **what** with files and directories. Think of them as the **traffic lights** for your files:

* **Red light (No access)** 🚫
* **Yellow light (Read-only)** 📄
* **Green light (Full access)** ✍️

***

#### 🏷️ **Types of Permissions** (It’s like having keys! 🔑)

* **Read (r)**: You can open and read the contents! 📖
* **Write (w)**: You can change or modify the file! 📝
* **Execute (x)**: You can run the file like a program or move inside directories! 🚶‍♂️

**These permissions apply to:**

1. **User (u)**: The file owner 👑
2. **Group (g)**: Other users in the same team 👥
3. **Others (o)**: Everybody else in the system 🌍

***

#### 🔠 **The 10-Character Permission String:**

Permissions are represented like this:\
**drwxrwxrwx**\
Let’s break it down:

1. **1st character**: `d` for directory, `-` for file.
2. **Next 9 characters**: Permissions for **user**, **group**, and **others**.

**Example:**

* `drwxr-x---`
  * `d`: It’s a directory.
  * **User**: `rwx` → Read, write, execute.
  * **Group**: `r-x` → Read, execute (but can’t write).
  * **Others**: `---` → No permissions.

***

#### 🕵️ **Checking Permissions with `ls` Command**

Want to see the permissions? Use the **`ls` command**! 📜

* **`ls -l`**: Shows file details and permissions.
* **`ls -a`**: Displays **hidden files** (those sneaky files with a `.` in front 🕵️‍♀️).
* **`ls -la`**: Combines both—shows **all** files with permissions, including hidden ones! 🎯

***

#### ✨ **Changing Permissions with `chmod`** ✨

The **`chmod` command** is your magic wand 🪄 for permissions!

Here’s how it works:

* **Add permissions**: `+`
* **Remove permissions**: `-`
* **Set exact permissions**: `=`

**Example:**\
To give the **user** full control, the **group** read access, and **others** no access:\
`chmod u=rwx,g=r,o= bonuses.txt`

***

#### 🎯 **Real-Life Example: Principle of Least Privilege**

**Scenario**:\
You’ve got a **super confidential file** called `bonuses.txt`. Only **hrrep1** should have access because it's sensitive.

1. Current permissions:\
   `-rw-rw----` (User and group both have read & write access 😬)
2. Fix it! We only want **hrrep1** to have access (no need for the group):

   ```bash
   chmod g-rw bonuses.txt
   ```

💡 **Boom!** Now only the file owner can access it, protecting the sensitive info like a **data ninja** 🥷.

***

#### 🏆 **Key Takeaways:**

1. **Permissions** are your gatekeepers—decide who gets to **read, write, or execute**!
2. **`ls -l`** is your permission detective 🕵️‍♂️.
3. **`chmod`** is your power tool for **changing permissions**.
4. Stick to the **principle of least privilege**—only give access where it’s needed! 🚪🔐

Now you’re ready to **conquer permissions** like a boss! 🎉
