Linux: File Permissions
Checking File Permissions
The 'ls -l' command can be used to check the current permissions on a file.
[michael@head ~]$ ls -l boston_ping.sh
-rwxr-xr-x. 1 michael michael 2199 Jul 3 08:59 boston_ping.shThe permissions are shown in the left hand column.
The first bit shows the type of file: - = Directory, d = directory, b = device, l = linked file
The next nine bits represent the file permissions.
The last bit may be a '.' showing that the file is under the control of SELinux. A '+' would show that it is under the control of SELinux and and Access Control List (ACL).
File Permissions
File permissions in Linux are divided into three groups: Users, Groups and Others. Each Group can have Read Write and Execute Permissions.
The file shown above has execute permissions for all groups, read permissions for the user and group, and write permissions only for the user.
Special Permissions
There are three special permissions: SUID, SGID and the Sticky Bit.
The SUID and SGID allow the file to be executed by others with the authority of the owner. An example of this is the passwd command.
ls - l /usr/bin/passwd
-rwsr-xr-x 1 root root 32200 Jan 28 2010 /usr/bin/passwdThe sticky but is shown in the execubte bit of the permissions such as the /tmp folder. The Sticky bit allow file to be copied to the directory while retaining ownership.
drwxrwxrwt. 31 root root 57344 Aug 15 20:09 tmp