chmod
Forget the chmod octals (the numbers). Set permission the easy way using the keywords
// know the ownerships:
u = User (you)
g = Group
o = Other (aka. 'World')
a = All of the above
// know the permission keywords
= (blank) no permissions
x = Execute
w = Write
r = Read
// use the operators
+ Add
- Remove
= Equals
, delimiter
// use:
u= : assign User 'blank', results in no permissions
u=r : assign user Read (only)
u+wx : Add Write and Excute to the User.
u-x : Remove Excute from User
a=r : assign Read (only) to All Owners
// CLI example:
$ chmod u=rwx foo.txt // User has full permissions
$ chmod u-wx foo.txt // User now only has Read permissions
$ chmod u-r,g+w,o= foo.txt // Remove Read from User, Add Write to Group, Set NO permissions to World
chmod (octals)
but it's good to know the octals
// Octal Permissions; know them, but you don't really have to use them
0 = none
1 = Execute
2 = Write
4 = Read
// the rest are simply combinations of the base Octals
3 is 1 + 2 : Execute and Write
5 is 1 + 4 : Execute and Read.
6 is 2 + 4 : Write and Read
7 is 1 + 2 + 4 : Execute, Write, Read
// eg.
$ chmod 640 foo.txt // '6' User can Read/Write; '4' Group can Read; '0' World has no permissions