There are three types of permissions for a file or directory:
read, write, and execute.
File
- Read: it is possible to see the contents of the file
- Write: it is possible to change the contents of the file
- Execute: the file contains machine code, or the file contains a
script and the name of a program to execute the script
Directory
- Read: it is possible to see the list of names of the files that are
in the directory
- Write: it is possible to change the list of names of the files that
are in the directory
- Execute: it is possible to access the files that are in the
directory. It is possible to change (cd) to the directory.
Each file has three different access permissions
- User: the owner of the file
- Group: the group that the user belongs to. A group allows different users to read and write a set of files. A group allows different users to read and write a set of files.
- Other: every other account that is neither the user nor a member of the file's group.
The output of thels -al
command lists all the permissions.
There are ten characters
- First character - type of file: d is directory, l is link, - is file
- The remaining are r (read), w (write), x (execute) and - (no permissions)
- First set of three - user permissions
- Second set of three - group permissions
- Third set of three - other permissions
Each permission is assigned a numeric value. Each number from 0 - 7 in binary indicates a unique combination of permissions of rwx.
- none: 0 (000)
- e: 1 (001)
- w: 2 (010)
- we: 3 (011)
- r: 4 (100)
- re: 5 (101)
- rw: 6 (110)
- rwe: 7 (111)
Calculate the number from 0 to 7 for each access category: user, group, other. Put them together to get a three digit permission number.
chmod 755 public_html
chmod 644 index.html
chmod 711 ~
chmod 600 httpd.conf
To get more information on the chmod command, use the man
pages.
- On ocelot:
man chmod
- Here are the explanations of the other modes in the ls command
- l - file locking. Only one process can access the file at one
time.
- t - sticky bit. If directory has write access, only owner of
the directory or a file in the directory can rename or remove the file.
- T - sticky bit but no access. Sticky bit is on, but directory
does not have execute permission.
- s - set-user or set-group ID. An executable file will run with the permissions of the user or group of the file.
- S - set-user or set-group ID but no access. Set-ID bit is on, but
directory does not have execute permission.
Back to top of page
Symbloic links are used in UNIX much like a shortcut is used in Windows.
A directory can create a link to a file in another directory. To the
operating system, this looks like the file exists in the current directory,
eventhough it actually exists in a different physical location.
To create a symbolic link:
- Change to the directory where the link is to be created.
- Issue the
ln -s
command with the path to the actual file
that is being linked
ln -s /path/to/real/someFile.ext
If the link was created, then you will see the name of the linked file
in the current directory, but it will be labeled as a link in a directory
lising,
lrwxrwxrwx someFile.ext
This means that the file is a link and that it will have the same
permissions as the actual file.
Back to Index