An essay on file permission in UNIX

Chmod is the name of Unix-Shell command and a system call, which both change the permission of the file system(including files and directories). The name chmod refers as Change Mode. A chmod command first appeared in AT&T Unix version 1.

File Permission allows user to access files and directory by changing the permission for a file.


Chmod Syntax : 

$ sudo chmod [references][operator][modes] filename


Where  'sudo' means super user.

'chmod' means Change Mode.

'modes' stand for
 r, w, and x which specify the read, write, and execute access, respectively. This script can be read, written to, and executed by the user, read and executed by other members of the staff group and can also be read by others.



'filename' includes that file which we want to change the permission of.


Numerical Representation

   If we provide the  sudo chmod 755  temp.txt .That means




The references (or classes) are used to distinguish the users to whom the permissions apply. 

If no references are specified it defaults to “all”.
The references are 

                       u = Owner(the owner of the file)
                       g = group members(users who are members of the file's group)
                       o = any other(not owner or group member)
                       a = all users( all three of the above)

The CHMOD uses an operator to specify how the modes of a file should be adjusted. The following operators are accepted:

     Operator      Description

        +                  add the specified modes to the specific classes
         -                  removes the specified modes from the specific classes
        =                  the modes specified are to be made the exact modes for the      
                            specified classes

  example of Chmod is given below :


Step 1. Write the command in terminal  ls -l temp and Press Enter.

The following output will be displayed
    
-rw-rw-r--  1      gyansha gyansha         0 May 29 12:11              temp

(rw-) means root has a permission for a temp file to read and write. he can not exceute the file.
(rw-) means super user has a permission to read and write the file.
(r--) means other users have permission to read-only file. 


If we want to change the permission of file

Step 2. Write the command in terminal : sudo chmod 777 temp and press Enter.

Permissions for a file has changed

-rwxrwxrwx  1      gyansha gyansha         0 May 29 12:30              temp




Previous
Next Post »

Popular Posts