Brief Guide To Ubuntu Permissions Part 2

Over a year and half ago, I posted a brief guide about Ubuntu permissions.

Whilst this covered most of the basics of Ubuntu permissions there was one part that I found myself looking into today: chmod.

You may or may not be familiar this command to change permissions. But the general usage is:

chmod 777 file.txt

In the above example, file.txt will be given complete read and write access for all users.

But where does 777 come from?

Well I’m glad you asked handsome stranger.

If you refer back to the original post, you will be reminded that permissions are split into three blocks:

  1. Permission for the user who owns the file.
  2. Permissions for the group that owns the file.
  3. Permissions for the rest of the world.

Each individual ‘7’ refers to each of those blocks in that order.

7 means all privileges for that section i.e. rwx. So 777 would be rwxrwxrwx. (Refer to the previous article for explanation of what r, w and x means).

Below shows what each number means:

7 = rwx
6 = rw-
5 = r-x
4 = r–
3 = -wx
2 = -w-
1 = –x
0 = —

So giving a file a privilege of 644 would mean, rw-r–r–, which means the owner can read and write in it only and everybody else can only read it.

But how can I remember those numbers?

Each privilege type is given a number as follows:

1 = execute
2 = write
4 = read

Simply add up the numbers of the privileges that you want to give. For example, read and write only would be 4 + 2 = 6, hence 6 is rw-.

Simple really isn’t it?

That is all for now. Thank you for reading!


© 2012-2017