Understanding Permission Symbols: r, w, x
Welcome to this beginner-friendly tutorial on Linux permissions!
In Linux, every file and directory has a set of permissions that define who can read, write, or execute it. These permissions are represented by the letters: r, w, and x.
What do these symbols mean?
- r (read) – Allows viewing the contents of a file or listing the contents of a directory.
- w (write) – Allows modifying a file or adding/removing files in a directory.
- x (execute) – Allows running a file (like a script), or entering a directory.
Let’s see permissions in action
We’ll use the ls -l command to list files along with their permissions.
ls -l
-rwxr-xr-- 1 user user 2048 Jul 1 10:00 hello.sh
This output shows a file named hello.sh. Let’s break down the leftmost part: -rwxr-xr--
Permission breakdown
| Part | Meaning |
|---|---|
| - | It's a file (d for directory, - for regular file) |
| rwx | User (owner) permissions: read, write, execute |
| r-x | Group permissions: read, execute (but not write) |
| r-- | Others: read only |
Try this example yourself
Create a file and check its default permissions:
touch myfile.txt
ls -l myfile.txt
-rw-r--r-- 1 user user 0 Jul 2 11:30 myfile.txt
This means:
- User can read and write the file
- Group can only read
- Others can only read
What about directories?
Directory permissions behave slightly differently:
- r – Can list directory contents
- w – Can create/delete files in the directory
- x – Can enter ("cd into") the directory
Let’s check a directory’s permissions:
mkdir testdir
ls -ld testdir
drwxr-xr-x 2 user user 4096 Jul 2 11:35 testdir
This means:
- User can list, write, and enter the directory
- Group and others can read and enter, but not modify
Quick tip: Use chmod to change permissions
For example, to add execute permission for everyone on a file:
chmod +x hello.sh
ls -l hello.sh
-rwxr-xr-x 1 user user 2048 Jul 2 11:40 hello.sh
Now everyone can execute the script!
Summary
Permissions are crucial to keeping your Linux system secure and organized. Knowing what r, w, and x mean will help you control access to your files and directories with confidence.
In upcoming lessons, we'll explore changing permissions using chmod, chown, and symbolic vs numeric modes. Stay tuned!
