|
Home » Other Tips » Hosting Issues » Linux File Permissions Linux File PermissionsFor those coming to the web from a Windows machine the idea of file permissions may seem like an odd concept. On your computer if you want to edit a file you can simply open it, make your changes, and save. Linux makes it a little more complicated, although necessarily so because Linux was written for network environments where Windows started life as an operating system for single computers and had network support added. Owner, Group, and World The file owner is generally the person who created the file. Say Bob saves all his finances in Quicken. The Quicken data files belong to Bob, so he would be the file owner. In most cases, all the files on your desktop computer are treated as though you own them. Bob's wife Joan decides she wants access to the finances, so Bob has to change the file permissions. But he can't simply change the file owner to Joan because then he couldn't access it. So Bob creates a group named Smith that both he and Joan belong to and assigns the Quicken file to that group. Bob is still the file owner, but because the file is also assigned to the Smith group Joan can access it. World permissions sort of make the Quicken example fall apart, so we need to move on to another file. Bob has a great picture of the Grand Canyon that he wants to share with anyone who comes to his computer. He sets this file to be readable by anybody whether they belong to the Smith group or not. But, he doesn't want just anyone writing over it so write permissions are saved for just Bob and Joan. Executable Text view of permissions -rwxrw-r-- Position 0 can be either -, d, or l. A normal file will have a - in this position, a directory will have a d, and a link will have an l. Positions 1-3 are for the file owner, positions 4-6 are for the group, and positions 7-9 are for the world. An r means that the file is readable, a w means writable, and an x means executable. For this particular file, let's say Bob is the owner and it belongs to the Smith group. Bob can read, write to, and execute the file. Bob and Joan can both read and write to the file. And anybody can read it. Numeric representation of permissions
Using the table above we can see that 755 means that a file is readable, writable, and executable by the owner and readable and writeable by the group and world. 644 means that the owner can read and write and the group and world can read only. These two cases, 755 and 644, are very common in web applications. |
