Yepp, Tutorial time again. I didn´t publish too many over the last few weeks, mainly due to me being really sick. Got the flu for almost two weeks, thanks god it´s almost gone now and i start to feel considerably better. Was a pain up the ar** sitting in front of the computer sick and working, so i did just what´s necessary to earn me money and let anything else rest in peace
Today i´ll try to explain to you what CHMOD is, and why sometimes you need to change, or respectively CHMOD permissions on files and folder on your FTP server for your scripts to work properly. I try to do it in layman´s terms since it actually is a very technical thing. The reason why i am doing that is because of quite a number of people on Forums, when being told to CHMOD the permissions of some files look a bit like this

And that is exactly why i want to avoid that look. Bad enough that i see that picture in the mirror every morning, well sort of…
The chmod command (abbreviated from change mode) is a shell command in Unix and Unix-like environments. When executed, the command can change file system modes of files and directories. The modes include permissions and special modes. That said we now know what it does. How does it do that and how can you make it do that ? Basically there are two ways, the first one very likely not being the one you will go for since you either have no clue as to what to do with a Unix shell or simply do not have shell access on your hosting. That leaves just one option, setting permissions via FTP client.
To give you an idea on how much fun you´re missing out when not using the shell here is a code sample to show how it´s done in a very basic way:
1: Sample file permissions before command
2: $ ls -ld sample
3: drw-rw---- 2 unixguy unixguy 08 Sep 17 09:53 sample
4:
5: $ chmod ug=rx sample
6:
7: Sample file permissions after command
8: $ ls -ld sample
9: dr-xr-x--- 2 unixguy unixguy 08 Sep 17 09:53 sample
Isn´t that cute ? Or scary ? Might be both hehe.
Anyway, there is a much more easier way for all those of you who like the warm and fuzzy feel of a GUI as offered by any FTP client. In this Tutorial i´ll be using FlashFXP, my first choice of FTP clients. So let´s fire up the client then and connect to the FTP server.
On my test server it looks like on this screenshot, yours actually shouldn´t be that different. No matter what FTP client you use, usually you will see a couple of columns such as filename, size, and attributes/permissions.

The highlighted part are the attributes or file permissions which we need to take care of. At the first glance they might look all cryptic and weird but those letters there all have a meaning:
r = read / read a file or list a directory’s contents
w = write / write to a file or directory
x = execute / execute a file or recurse a directory tree
That are the basic permissions, in case you wonder what the “d” stands for….This just indicates that it´s a directory. You will only see a “d” in the attribute list of directories. Taking a second look at the attributes now knowing what they mean makes it a bit easier to understand how those permissions work and help you when looking at the CHMOD screen of your FTP client.
In the next screenshot i picked a random file for which i want to change permission, did a right-click on it and selected CHMOD from the context menu. It works this way on almost all of the FTP clients i used so far. That means chances are pretty good that it will work on the one you are using too. So have a look at the screenshot and what permissions look like on it.

Wow, thanks to the GUI we can now select what the permissions should look like by just clicking the appropriate permission. Most of the times your script, or better the installation routine of your script will tell you what files and folders need their permission changed and what they need it changed to. When for example your script asks you to change the permission of a directory to CHMOD 777 then you would have to click the appropriate boxes, CHMOD 777 being all of them. How that number behind CHMOD is calculated is a very tricky thing of which i am sure you don´t want to bother with. Just so you know here is a short introduction on how they are calculated:
Octal notationAnother common method for representing Unix permissions is octal notation. Octal notation consists of a three- or four-digit base-8 value. With three-digit octal notation, each numeral represents a different component of the permission set: user class, group class, and “others” class respectively.
Each of these digits is the sum of its component bits (see also Binary numeral system). As a result, specific bits add to the sum as it is represented by a numeral:
* The read bit adds 4 to its total (in binary 100),
* The write bit adds 2 to its total (in binary 010), and
* The execute bit adds 1 to its total (in binary 001).
These values never produce ambiguous combinations; each sum represents a specific set of permissions.
These are the examples from the Symbolic notation section given in octal notation:
* “-rwxr-xr-x” would be represented as 755 in three-digit octal.
* “-rw-rw-r–” would be represented as 664 in three-digit octal.
* “-r-x——” would be represented as 500 in three-digit octal.
Here is a summary of the meanings for individual octal digit values:
1 --x execute
2 -w- write
3 -wx write and execute
4 r-- read
5 r-x read and execute
6 rw- read and write
7 rwx read, write and execute
Feeling lost now ? That´s ok, so did i when i first had to deal with CHMOD. Basically most of the scripts require some CHMOD at some point, most of the times during installation where you have to make sure that for example configuration files are writeable, upload directories or other directories where files are written to, etc. As i already said the script or it´s documentation usually tells you which files and folders to change. And with the help of a FTP client that also allows manual input of the CHMOD numbers as shown in the screenshot above is a real help as you only have to put in the numbers the script tells you and click OK.
Anyway, if you need help with CHMOD some files on your system leave me a comment i´ll see what i can do