Thursday, 17 March 2016

A Quick CHMOD reference

CHMOD can be written in one of two ways - either numerically e.g. chmod 777 or with lettering e.g. chmod g=rwx,o=rwx,u=rxw

The above two command are equal to one another - the numbers are added as follows:

read=4
write=2
execute=1


+r      add read perms for others, owner and group
+x    
add execute perms for others, owner and group
+w    
add write perms for others, owner and group

a+rw = add read and write perms for others, group and owner
a+x = add execute perms for others, group and owner.

g-xw = remove execute and write perms for the group
o-rwx = remove read, write and execute from others.
u+r = add read permissions for owner

chmod u=xwr, g=, o= This sets the permissions so owner can execute,
write and read, although group and others have no permissions to do anything.

chmod 1777 This sets the permissions so that the owner, group and
others can read write and execute - although the 1 at the beginning is
called the 'sticky bit' that ensures Only the owner a delete the file!

chmod 2755 The two at the beginning sets the GID (group id) - this
means that any other user that creates a file or folder within the folders
heirarchy will automatically inherit / belong to the group of the parent
folder - not the group of the user that created it!

When dealing with chmod and directories it is slightly different.

When giving the read permission to let's say to 'others' they will only be
able to list the directory contents and nothing else.

In order to rename, delete, add and modify files (and also cd to the
directory) we need to set the write permissions AND the execute permissions
(write permissions on their own are useless!)

0 comments:

Post a comment