Categories
GNU/Linux

Demystifying Unix File Permissions

Never really understood what was going on with Linux File Permissions and chmod?

If you understand binary then this will be a piece of cake. Here is a simple blog post to demystify Unix File Permissions:

Ever seen:

-rwxr-xr--  1 dgerman  staff  823 Dec 16 15:03 findPhoneNumbers.sh

Operations:

  • r – Read
  • w – Write
  • x – Execute

Now why are there 3 sets of rwx?

  1. User – The owner of the file
  2. Group – The group owning the file
  3. Others (Rest of the World) – anyone

Below is a table Showing numeric permissions.

# Permission rwx
7 read, write and execute 111
6 read and write 110
5 read and execute 101
4 read only 100
3 write and execute 011
2 write only 010
1 execute only 001
0 none 000

When you give a 777 permission to a file/folder, you are giving user, group and anyone ((20 x 1 + (21 x 1 + 22 x 1)) = 7. That is Read, write and Execute.