Untitled Document
chmod Command

chmod command is used for changing and managing the file permissions . We have already seen the deatils about file permission in chpater - 6 . Please Go through the chapter for more details . We will see all the possible combinations of file permissions with chmod in below examples . We can give permission using Relative and Absoulte method , the examples will show the synatx for both type of methods.

1. Basic example -

Create a file user.txt and give all the permission to the file ..

   chmod 777 user.txt     --- this is Absolute Permission 
   chmod a+rwx user.txt   --- this is Relative Permission OR 
   chmod ugo+rwx user.txt --- one more way to give Relative Permission  

2. Give Read permission to a file for all and remove all other permissions on file -

   chmod 444 user.txt    --- this is Absolute Permission
   chmod ugo+w user.txt  --- this is Relative Permission  

3. Give Write permission to a file for all and remove all other permissions on file -

   chmod 222 user.txt    --- this is Absolute Permission
   chmod ugo+r user.txt  --- this is Relative Permission

4.Give Execute permission to a file for all and remove all other permissions on file -

 chmod 111 user.txt --- this is Absolute Permission

5. Give Read and write permission to a file for all and remove all other permissions on file -

    chmod 666 user.txt --- this is Absolute Permission

6. Give Read and Execute permission to a file for all and remove all other permissions on file -

chmod 555 user.txt --- this is Absolute Permission

7. Give Write and Execute permission to a file for all and remove all other permissions on file -

chmod 333 user.txt --- this is Absolute Permission

8. Give read, Write and Execute permission to user . group and others just Read permission -

chmod 744 user.txt --- this is Absolute Permission

9. Give Read and Execute Permission to Other. All permissions to Group and User should have Read and write -

chmod 673 user.txt --- this is Absolute Permission
Untitled Document