Thursday, July 7, 2011

File and Directory Permissions

File Permissions:
1. -r--
content of the file can be read using command such as cat, less or more.
2. -rw-
Note: read permission is required to write into any file.
file can be edited and saved
3. -r-x
Note: read permission is required to execute any file.
shell (bash or sh, etc) will attempt to execute the file when file's name is entered as a command.

Directory Permissions:
1. dr--
content of directory can be read as ls.
Few examples:
$ ls testing/
ls: cannot access testing/file2: Permission denied
ls: cannot access testing/file1: Permission denied
file1 file2

Note: long listing requires execute permission.
Few examples:
$ ll testing/
ls: cannot access testing/file2: Permission denied
ls: cannot access testing/file1: Permission denied
total 0
-????????? ? ? ? ? ? file1
-????????? ? ? ? ? ? file2

2. d-wx
files may be created or delected in the directory.
Note:
a). execute permission required.
b). A file can be deleted by anyone who has write permission to directory in which the file resides regardless of the ownership or permission for that file.
Few examples:
a). $ ls testing/ [Failed]
ls: cannot open directory .: Permission denied

3. d--x
enter into directory using command cd
Few examples:
a). $ ls testing/
ls: cannot open directory testing/: Permission denied
b). $ cd testing/ [Okay]

No comments:

Post a Comment