## Linux Permissions

Linux is a multi-user OS. Permissions decide who can Read, Write, or Execute.

### The Output of `ls -l`
Example: `-rwxr-xr-- 1 owner group size date file`

The first part `rwxr-xr--` tells the story.
It is split into 3 groups of 3 characters:
1.  **User (Owner)**: `rwx` (Read, Write, Execute).
2.  **Group**: `r-x` (Read, Execute. No Write).
3.  **Others (World)**: `r--` (Read only).

### The Modes
*   **r (Read)**:
    *   File: View contents.
    *   Dir: List contents (`ls`).
*   **w (Write)**:
    *   File: Modify/Delete content.
    *   Dir: Create/Delete files inside it.
*   **x (Execute)**:
    *   File: Run as a program/script.
    *   Dir: Enter the directory (`cd`).

### Changing Permissions (`chmod`)
You can use numbers (Octal) or letters.

**The Numbers**:
*   Read = 4
*   Write = 2
*   Execute = 1
*   Total = 7

**Common Sets**:
*   `chmod 777 file`: Everyone can do everything. **Insecure**.
*   `chmod 700 file`: Only I (User) can read/write/run. Private keys usually need this.
*   `chmod 755 file`: I can do all. Everyone else can Read/Run. (Standard for scripts).
*   `chmod +x file`: Quick way to make a script executable.

### Changing Owner (`chown`)
*   `chown user:group file`
*   `chown root:root /etc/shadow`