🎓 A1Learner
🔍
0 of 50 lessons completed

Reading Permissions

A permission is a yes or no for reading, writing, or running a file. The letters r, w, and x spell out those three answers.

Read the letters

The line starts with ten signs. The first sign is a dash.

$ cd ~/practice
$ ls -l projects/report.txt

The same letters from stat

Stat prints the same letters in a short line.

$ cd ~/practice
$ stat -c '%A %a %n' projects/report.txt

Example

$ cd ~/practice
$ ls -l data/logs.txt
$ stat -c '%A %a %n' data/logs.txt

Key points

  • Read means look at the contents of a file.
  • Write means change the contents of a file.
  • Execute means run a file.
  • The nine letters come in three sets of three.
  • The first set is for the owner, the second for the group, and the third for everyone else.
  • The letters spell out who can read, write, or run a file.

In this example, the letters read -rw-rw----. The owner can read and write. The group can read and write. Everyone else has three dashes, so no read, no write, and no run. Stat prints the same letters again, with 660 beside them.

Note

The owner and group names differ on each machine, so yours will differ from the ones shown here.

Try it Yourself

Edit the code, then press Run.

Running is simulated

Exercise

What does the letter x mean in a permission?