Unix File Access Permissions - Chmod


chmod: It provides permissions over a file in 3 catagories.

1) owners

2) groups

3) others

Permissions which can be granted are read,write and execute

1) read (r)

2) write (w)

3) execute (e)

These permissions are represented with numeric values

r -   4

w -  2

e -   1
-----------
       7
-----------

Owners are users whose files gets referred from their respective accounts.

Groups are users whose accounts are dependent on the other accounts.

Others are users who can access the files of other users.

Chmod command is used to change the permissions for a file or directory.

Syntax:

$ chmod  FAP  Filename    

* FAP is file access permissions

Examples:

$ chmod ooo  paypal.txt

No permissions to owners,groups and others

$ chmod 777  paypal.txt

All permissions to owners,groups and others

$ chmod 444  paypal.txt

Read permission to owners,groups and others (4 - read)


$ chmod 600  paypal.txt

Read(4),write(2) permissions to owners, no permissions to groups and others

$ chmod 664  paypal.txt

Read,write permissions to owners,groups and read permission to others

$ chmode 111 paypal.txt

Execute permission to owners,groups and others

Change permissions using name of the permission:

Examples:

$ chmod  u-w  g-w  o-r  paypal.txt

* write permission cancelled from owner
* write permission cancelled from groups
* read permission cancelled from others

$ chmod  u+rwx  g+rwx  o+r  paypal.txt

* read,write,execute permissions added to owners
* read,write,execute permissions added to groups
* read permission added to others

** Note: +   used for giving permissions.

              -   is used for removing permissions.

Followers