One of the thing that I have noticed recently is people asking about setting file permissions on files and not knowing the difference between Windows and Linux file systems. On the Windows file system you have for your users
Read Read & Execute Write Modify Full control Special permissions
Where as the Linux system has for users groups and other
Read (4) Write (2) Execute (1)
Here I am only going to go into the Linux file system but note that Windows is very different and can be a lot more complicated. To start lets get to grips with the basic permission, from the command line if you do an ‘ls -l’ this will list the files in your current directory you should get an output similar to the following.
The first thing to note is that their is 4 items 3 files and 1 directory/folder. when looking at the list to determine which is the folder you will need to look at the 1st column where you see the rwx details, if this starts with a d then this indicates that this is a directory, you can work out the permission by simply looking at this, this is built up in 3 groups of rwx or a – where no permission is granted.
drwxr-xr-x
Indicates a directory
Indicates the owners permissions
Indicates the group permissions
Indicates the other permissions (every one else/anyone)
as you can see from the image ‘images’ is a directory
drwxr-xr-x 2 root root 4096 Apr 23 20:25 images
In most cases directory’s have a 755 permission set this means that the user that created the directory has full permissions, the group and other has read and execute permissions.
As you will see the permissions on the other files are set differently, when setting the permission this can be done in many ways the most common way from the command line is with chmod
chmod 755 menu.php
you can work out what to set in a simple way, each permission has a value and by adding up the values you can work out how to set the permissions you need for user,group and other
- Read = 4
- Write = 2
- Execute = 1
if you require full permissions for the and only read and execute group and other you would do the following
- User = Read Write Execute – 4+2+1=7
- Group = Read Execute – 4+1=5
- Other = Read Execute – 4+1=5
by working it out this way you can set any permission that you may require on a file, if you are using an FTP client the you may also be able to set file permissions and is very handy when working with websites that require specific permission on files and folders.