Menu
Coddy logo textTech

Reading Permissions

Part of the Fundamentals section of Coddy's Terminal journey — lesson 54 of 82.

Now that you understand what permissions are, let's learn how to read the permission string that ls -l displays.

The permission string has 10 characters. The first character indicates the type: - for a regular file, d for a directory. The remaining 9 characters are divided into three groups of three:

-rwxr-xr--
│└┬┘└┬┘└┬┘
│ │  │  └── Others: r-- (read only)
│ │  └───── Group:  r-x (read and execute)
│ └──────── Owner:  rwx (read, write, execute)
└────────── Type:   - (regular file)

Each position in a group represents a specific permission. If the letter is present, the permission is granted. If there's a dash -, the permission is denied.

PositionLetterMeaning
1strRead
2ndwWrite
3rdxExecute

So r-x means read and execute are allowed, but write is not. And rw- means read and write are allowed, but execute is not.

challenge icon

Challenge

Easy

Use ls -l to display the detailed file listing and examine the permission strings for each item.

Look at the output and identify the permissions for each file and directory. For each item, read the 10-character permission string and determine:

  • Whether it's a file (-) or directory (d)
  • What permissions the owner has (first group of three)
  • What permissions the group has (second group of three)
  • What permissions others have (third group of three)

Run the command:

ls -l

In the output, notice how backup.sh has execute permission (x) for the owner, making it runnable as a script. Compare this to report.txt and config.cfg which are regular files without execute permission.

Also observe how the projects directory starts with d instead of -, and has execute permission which allows users to enter the directory.

Cheat sheet

The permission string displayed by ls -l has 10 characters:

-rwxr-xr--
│└┬┘└┬┘└┬┘
│ │  │  └── Others: r-- (read only)
│ │  └───── Group:  r-x (read and execute)
│ └──────── Owner:  rwx (read, write, execute)
└────────── Type:   - (regular file)

The first character indicates the type:

  • - for a regular file
  • d for a directory

The remaining 9 characters are divided into three groups of three, representing permissions for owner, group, and others.

Each position represents a specific permission:

PositionLetterMeaning
1strRead
2ndwWrite
3rdxExecute

If the letter is present, the permission is granted. If there's a dash -, the permission is denied.

Examples:

  • r-x means read and execute are allowed, but write is not
  • rw- means read and write are allowed, but execute is not

Try it yourself

Terminal
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Fundamentals