TutsFx logo

Linux File Permissions Explained

Reading Permission Bits

2 min read Last updated 44 minutes ago

Run ls -l in any directory and every line starts with ten characters:

bash
$ ls -l notes.txt
-rw-r--r-- 1 alice developers 120 Aug 12 10:30 notes.txt

Breaking down the first ten characters

Code
-rw-r--r--
Characters Meaning
- (position 1) File type. - = regular file, d = directory, l = symlink
rw- (2-4) Owner permissions
r-- (5-7) Group permissions
r-- (8-10) Others (everyone else) permissions

The three permission letters

Letter Meaning On a file On a directory
r read View contents List the directory's files
w write Modify the file Create or delete files inside
x execute Run as a program Enter the directory (cd)

A - in any position means that permission is absent. rw- means read and write, but not execute.

Directories need `x` to enter

A directory with permissions drw-r--r-- cannot be entered with cd, even though the owner can read its file list. The execute bit on a directory means "allowed to traverse into it."

Who is the owner and group?

Looking again at the full line:

Code
-rw-r--r-- 1 alice developers 120 ...
  • alice is the owner
  • developers is the group
  • 120 is the size in bytes

The three triads apply to exactly these three groups: the owner, members of the group, and everybody else.

Try it

  1. cd ~ && touch demo.txt && ls -l demo.txt
  2. ls -ld /etc /tmp /home — note the leading d and the execute bits on directories
  3. ls -la in your home directory — spot the files that start with a dot
Share:

We value your privacy

We use cookies to enhance your browsing experience, serve personalized ads, and analyze traffic. By clicking "Accept", you consent to our use of cookies. Read our Privacy Policy to learn more.