Linux File Permissions

File Permissions
Every file on the system has associated with it a set of permissions. Permissions tell UNIX what can be done with that file and by whom. There are three things you can (or can’t) do with a given file:

  • r : read it,
  • w : write (modify) it and
  • x : execute it.

$ chmod [options] mode file(s)

chmod a-x file

This means that the execute bit should be cleared (-) for all users. (owner, group and the rest of the world) The permissions start with a letter specifying what users should be affected by the change, this might be any of the following:

  • u – the owner user
  • g – the owner group
  • o – others (neither u, nor g)
  • a – all users

This is followed by a change instruction which consists of a +(set bit) or -(clear bit) and the letter corresponding to the bit that should be changed.
Every one of the three digits on the mode number corresponds to one of the three permission triplets. (u, g and o) Every permission bit in a triplet corresponds to a value: 4 for r, 2 for w, 1 for x.

Triplet for u: rwx => 4 + 2 + 1 = 7
Triplet for g: r-x => 4 + 0 + 1 = 5
Tripler for o: r-x => 4 + 0 + 1 = 5
Which makes : 755

So, 755 is a terse way to say ‘I don’t mind if other people read or run this file, but only I should be able to modify it’ and 777 means ‘everyone has full access to this file’

Change multiple folder and file permissions recursively
$ chmod 755 'Folder' -R

Change multiple folder and file owner and Group recursively
chown user:group 'Folder' -R

Author: Suthar Naveen P

A Linux enthusiast. Full Stack Web Developer and Graphic Designer works on Debian Linux. Founder of 'Naveen Web Solutions' and contributor at Shutterstock.