Chapter 45: File Permissions

File Permissions

This is one of the most important topics in Linux/Bash — once you understand file permissions, you will never be confused again when you see “Permission denied”, or when a script won’t run, or when you wonder why your friend can’t read your file.

In Linux (and macOS, and servers), every file and every folder has permissions attached to it — like invisible rules that say:

  • Who can read it?
  • Who can write (change/delete) it?
  • Who can execute it (run it as a program/script)?

These rules are controlled by three categories of people:

  1. Owner (the user who created the file — usually you)
  2. Group (a group the owner belongs to — can be shared with teammates)
  3. Others (everyone else on the system — including visitors or other users)

And for each of these three categories, there are three possible permissions:

Letter Permission What it means for files What it means for folders
r read Can view / open / cat the content Can list files inside (ls)
w write Can edit / change / delete the file Can create/delete/rename files inside folder
x execute Can run the file as a program/script Can enter the folder (cd into it)

How Permissions Look in Real Life (ls -l)

Type this right now in your terminal:

Bash

You will see lines like this:

text

Let’s break down one line completely:

text
  • First character = file type
    • – = normal file
    • d = directory (folder)
    • l = symbolic link
    • etc.

Next 9 characters = permissions (3 groups × 3 bits)

text

So for report.pdf above:

  • Owner (webliance): read + write (can edit/delete)
  • Group (webliance): read only (can view)
  • Others: read only (can view)

For hello.sh:

text
  • Owner: read + write + execute (full control)
  • Group & others: read + execute (can run the script, but cannot edit)

For folders (d at start):

text
  • Owner: rwx (can list, create/delete inside, cd into)
  • Group & others: r-x (can list files and cd into, but cannot create/delete inside)

How to Remember the 9 Positions

Think of it like this:

text

Each group has rwx (read-write-execute)

Numeric (Octal) Way – Very Common in Scripts & chmod

Permissions are also written as numbers (0–7 for each group)

Permission combo Binary Number (octal) Meaning shorthand
rwx 111 7 full
rw- 110 6 read + write
r-x 101 5 read + execute
r– 100 4 read only
000 0 nothing

So the famous permissions you see:

text

How to Change Permissions – chmod Command

chmod = change mode

Two ways:

  1. Symbolic (letters – easier for beginners)
Bash

u = user/owner g = group o = others a = all

  • = add permission
  • = remove = = set exactly
  1. Numeric (octal – faster once you remember)
Bash

Real-Life Examples You Will See Every Day

Bash

Practice Right Now (5 Minutes!)

Bash

Quick Summary Table – Most Common Permissions

Permission Octal Symbolic Typical Use Case
rw-r–r– 644 u=rw,go=r Normal text files, configs
rwxr-xr-x 755 u=rwx,go=rx Scripts, binaries, most folders
rw——- 600 u=rw,go= Private keys, passwords, .env files
rwx—— 700 u=rwx,go= Private folders (like ~/.ssh)
rwxrwxr-x 775 ug=rwx,o=rx Shared team folders
rw-rw-rw- 666 ugo=rw World-writable files (rare, dangerous)

Got it, boss? File permissions are Linux’s way of saying “who is allowed to do what” — master them and you’ll fix 80% of “permission denied” problems forever.

Any confusion? Want next: “Teacher, explain chmod recursive (-R)” or “what is umask” or “file ownership (chown/chgrp)” or “sticky bit & setgid”?

Just say — teacher is ready in Hyderabad! Keep checking ls -l every day! 🐧🔐📁 😄

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *