File and Directory Permissions
File and directory permissions are a fundamental part of Linux security, controlling who can read, write, and execute a file or directory.
The `ls -l` Output
When you run `ls -l`, the first column of the output shows the permissions.
-rw-r--r-- 1 user group 4.0K May 15 10:00 file.txt
drwxr-xr-x 2 user group 4.0K May 15 10:00 directory
The first character indicates the file type (`-` for a regular file, `d` for a directory). The following nine characters are the permissions, in three sets of three.
Understanding Permission Sets
| Characters | Permissions For |
|---|---|
| `rwx` | **Owner** (The user who owns the file) |
| `r--` | **Group** (Members of the file's group) |
| `r--` | **Others** (All other users) |
The Permissions
| Character | Permission |
|---|---|
| `r` | **Read**: Permission to read a file or list a directory's contents. |
| `w` | **Write**: Permission to modify a file or create/delete files in a directory. |
| `x` | **Execute**: Permission to run a file (if it's a script or program) or enter a directory. |