Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

File and Directory Permission

File and Directory:

‘ll’ is used to display the information about the files and directory including date, time, users,group, size, name and Permission.

Four symbols are used when displaying permission.

R : Read

W : Write

X : Execute

- : no permission

-rwxrwxrwx : files

drwxrwxrwx : directory

files and directory permission are symbolized by ten character.

If we want to change permission, then there are two methods:

  1. symbolic
  2. Numeric

  1. Symbolic Method:

Syntax:

Chmod mode directory/filename

Mode Option:

  1. u,g,o
  2. w,r,x
  3. +,-
  4. =

  1. # chmod u+rwx file or directory : in case of user only
  2. # chmod ug+rwx file or directoty : in case of user and group
  3. # chmod u+w,g+r,o+x directory/file
  4. # chmod u+rw,g+rw directory/file
  5. # chmod u-r, g-w,o-rw directory/file
  6. # chmod ugo+rwx file/directory
  7. # chmod ugo-rwx file/directory

  • + is used to add permission
  • - is used remove permission

chmod ugo=rw directory/file

this command will assign read/write permission to u,g,o

suppose we have one file as

test.txt

permission : -r- - r- -r- -

chmod u=w,g=wx,o=w test.txt

this command will assign write to user, write/execute to group and write to other while remove the previous permission.

The main difference between +,= are + operator simply add the new permission with previous one and = assign the new permission while removing old (new permission overwrite an old)

  1. Numeric Method:

In this method, calculation are based on following numbers

r=4 w=2 x=1 0= no permission

Example:

#chmod 777 file/directory

in this case user get 7 means that user has permission of read/write/execute, group get 7 means read/write/execute and ame for other

# chmod 531 file/directory

in this case user get 5 means that user has permission of read/execute, group get 3 means write/execute and other get 1 means that other has permission to execute.

#chmod 742 file/directory

7 : User : rwx

4 :Group : r

2 : Other : w



This post first appeared on RED HAT ENTERPRISE LINUX, please read the originial post: here

Share the post

File and Directory Permission

×

Subscribe to Red Hat Enterprise Linux

Get updates delivered right to your inbox!

Thank you for your subscription

×