Linux Permissions Explained
The Linux operating system provides distinct permissions for who can read, write or execute a certain file based on the file's ownership. Everyone can view what the file permissions are, but only the file owner or the root user (administrator) can change the permissions on a file.
-
Listing Permissions
-
You can see what permissions each directory and file has by issuing the "ls -l" command. The first part of each line of the result shows the permissions in the form: "-rwxr-xr-x." The very first character is reserved for designating the file type. The rest of the characters are the permissions.
Permission Categories
-
Linux permissions are separated into categories, with three characters (r, w, x) for each category. The first category is the owner of the file. The second category is the group owner. The third category is others. The permission categories are broken up in the following way: "-|rwx|r-x|r-x."
-
Types of Permissions
-
Each file can have "read" (r), "write" (w) and "execute" (x) permissions for each permission category. In the example, "-rwxr-xr-x," the owner has read, write and execute permissions; the group has read and execute permissions, but not write permissions; the others category also has read and execute permissions, but not write permissions.
Octal Values for Permissions
-
Permissions can also be designated by a numeric value, called the octal value. Each permission type has a different number. Read is designated by the number 4; write is designated by the number 2; and execute by the number 1. When designating the permissions for each category, you add the numbers to reach the octal notation. The example "-rwxr-xr-x" would have the octal value of 755.
Changing Permissions
-
The "chmod" command is used to change permissions. To change the permissions with the letter designations, you use the letters "u" (user, or owner), "g" (group), "o" (others), the plus sign (+) and the permissions. For example, if you want to give the "others" category read and write permission, you would type "chmod o+rw." You can also use the octal values. You would use the command "chmod 766" if you wanted to give the user read write and execute permission, and everyone else only read permissions.
-