Kahibaro
Discord Login Register

Permission types (r, w, x)

Understanding Permission Types: `r`, `w`, `x`

In this chapter, we focus specifically on what the three basic permission bits mean and how they behave differently for files and directories.

You’ve already seen that every file and directory has permissions and an owner/group; here we drill into the meaning of each of the three letters: r, w, and x.


The Three Basic Permissions

For both files and directories, Linux defines three basic permission types:

Each of these can be set or unset for:

You’ll usually see them in groups of three, like rwx, rw-, r--, etc.

Example from ls -l:

-rwxr-x---

Breakdown:

This chapter is about interpreting each r, w, x in these positions.


Permissions on Regular Files

`r` (read) on files

r on a file means:

Without r on a file:

`w` (write) on files

w on a file means:

Without w on a file:

Common misconception:

`x` (execute) on files

x on a file means:

Without x on a file:

  python script.py
  bash script.sh

In those cases, you only need r (the interpreter reads the file); the script itself doesn’t need x.

Typical combinations you’ll see on files:

Permissions on Directories

Permissions on directories behave differently. They control not the directory file’s contents, but what you can do with the entries inside the directory: listing, entering, creating, deleting, and renaming files.

Think: a directory is a list of filenames → inodes (entries). Directory permissions control access to that list and the ability to change it.

`r` (read) on directories

r on a directory means:

Without r on a directory:

`x` (execute) on directories

On directories, x is often called search or traverse permission.

x on a directory means:

Without x on a directory:

The combination of r and x is very important for directories:

`w` (write) on directories

w on a directory means:

Without w on a directory:

Important interaction:

Typical directory permission combinations

Some common examples:

File vs Directory Permissions: Summary Table

PermissionOn a fileOn a directory
rRead file contentsList directory entries (e.g., ls)
wModify file contentsCreate/delete/rename entries inside directory
xExecute file as a program/scriptTraverse/search: cd into, access entries by name

Key idea: file permissions affect the contents of that file; directory permissions affect the list of filenames and your ability to traverse the path.


How Permissions Appear in `ls -l`

When you run ls -l, you’ll see a 10-character string at the start of each line:

drwxr-xr-x  2 alice users  4096 Dec 12 10:00 docs
-rw-r-----  1 alice users  1024 Dec 12 10:05 notes.txt

Breakdown:

You now know how to interpret each r, w, x in these positions differently depending on whether the item is a file or a directory.


Practical Mental Model

Understanding this distinction is crucial before you start changing permissions and ownership, which are handled in separate chapters.

Views: 26

Comments

Please login to add a comment.

Don't have an account? Register now!