File permissions are particularly useful in web development, as they keep people from messing with your stuff. This is obviously very important. First, type “ls –l”. As you surely remember, this will give you a list of the directories and files in the current directory with full details.
The first part of each list item is the permissions for that item. The first character in that will tell you if it’s a directory ‘d’ or a file ‘-‘. After that come the permissions. The first set of three is for the user, the second is for the group, and the third is for others. There are three characters in each of these, delineating the specific permissions for each section: ‘r’, ‘w’ and ‘x’, or if any of those are not allowed, a hyphen.
r is the read permission, allowing viewing of the directory or file
w is the write permission, allowing editing
x is execute, allowing running of programs, or viewing of directories
There are several ways to set permissions with the same command, I’ll be explaining the quickest method to setting them all. To understand this method, you need to understand binary. Each section (user, group, others), separately, is a binary string. A string of “rwx” would be equivalent to 111 in binary, which is equal to 7 in decimal. A string of “---“ would be 000 in binary, or 0 in decimal. A string of “r-x” would be 101 in binary, or 5 in decimal. Directories generally have permissions of “rwxr-xr-x,” or 755, and files usually have permissions of “rw-r—r—,“ or 644.
Previous Home Next