SSH

File and Directory Permissions in UNIX

File and directory permissions control the ability of users to view and/or make changes to the files and directories in the file system. In UNIX, there are three types of access modes:

Access modes are specified for each file and directory three times, for the following distinct classes:

For example, in -rwxr-xr-x

File permissions can also be expressed in octal (base-8) notation, which consists of three digits. The first digit specifies the permissions given to the owner of the file, the second digit specifies the permissions for the user group associated with the file, and the last digit specifies the permissions given to all other users.

Table A.1. Permission bits in octal and symbolic notation

Octal notationSymbolic notationMeaning
0---No access
1--xExecute-only
2-w-Write-only
3-wxWrite and execute
4r--Read-only
5r-xRead and execute
6rw-Read and write
7rwxRead, write and execute

For example, 755 (equivalent to -rwxr-xr-x) specifies that the owner of the file has full permissions to the file, and the user group and others are allowed to read and execute the file.

700 (equivalent to -rwx------) specifies that the owner of the file has full permissions to the file, and the user group and others do not have access to the file.

To see the permissions of a file in USS, enter the following:

> ls -l filename

The ls -l command lists files in the long format, showing their file type, permissions, number of hard links, file owner, group, file size, and the date of last modification. If you do not specify a file name, the command lists the information for all the files in your current working directory.