Skip to content
BENIBIX Learn

File Permissions

Infrastructure⌨️ Linux & the Command LineUsers and Permissions

Also known as Linux File Permissions, Unix Permissions, rwx Permissions

Rules for who may read, change or run a file on Linux.

Think of it like

Think of it like rules on a diary. The owner can write in it. Friends can read it. No one else can.

Example

Lucy's script shows rwxr-x---. She can read, change and run it. Her group can read and run it. Nobody else can touch it.

Why it matters

They stop one user from reading or breaking the files of another. A broken app is held back too.

Definition

File permissions are the rules for who may use a file on Linux. There are three kinds of right: read, write and run. They are set for three sets of people: the owner, the owner's group and everyone else. ls -l shows them as letters, like rwxr-x---. Each set can also be written as a number from 0 to 7.

Example code

console
$ ls -l run.sh
-rwxr-x--- 1 lucy devs 120 Nov 16 09:30 run.sh
Three letters for the owner, three for the group and three for everyone else.
The letters split into three sets. The owner gets the most, and everyone else here gets nothing.

Common mistake

Fixing an error by opening a file to everyone with 777. Anyone on the machine can then change it.

Key takeaways

  1. 1
    Read, write, run. Three kinds of right.
  2. 2
    Owner, group, others. Three sets of people.
  3. 3
    Least you need. Give no more than the job needs.

Learn it properly