File PermissionsThis document provides an introduction to UNIX file permissions. You should also read Secure File Permissions for information on sensible permission settings.
What are file permissions?File permissions control who can access your files. It is important to keep permissions in mind so that others can't view private files, or worse, edit or delete them. Every file and directory has permissions. You can view them by using the -l flag on the ls command. For example:
$ ls -l file -rwxr-x--- 1 jsmith jsmith 1918 Mar 5 08:36 fileThe fields on this line are (bold being the interesting ones):
- The file permissions
- The number of hard links to the file (you can generally ignore this)
- The owner of the file
- The group-owner of the file
- The size of the file
- The date the file was last modified
- The file name.
- read - The file can be viewed by a person, or read by a program
- write - The file can be changed by a person, or written-to by a program. A person with write access can add to a file, or completely blank it.
- execute - The file can be executed as a command. Note that this is usually only set if it is a binary program or script.
|The owner of the file can read, write or execute this file.||The group-owner of the file can read or execute the file, but they can't modify it.||Anyone else has no access to the file - they can't read, write or execute it.|