As promised, in this blog article, we explain how to change Folder and File Permissions using an FTP Client. In our previous blog article on changing file permissions, we mentioned that we'd write a blog article on how to change permissions when you don't have access to the command line.
For those on VPS/Dedicated hosting who can access the server directly they normally have the choice of using either the command line or FTP to change folder and file permissions.
When setting up a website or blog, you'll will need to be able to change the permissions of files on the server. This is required in order to setup a content management system and database, but is also required if you wish to protect certain files from unauthorized visitors. There are a lot of different website hosting solutions and a lot of them don't come with access to the server command line. This generally applies to shared hosting or shared cloud services where the hosting service manages the servers and the client's access is limited to the web interface provided by their host. Nearly all hosts provide FTP (File Transfer Protocol) access to their services, as this is one of the few ways people using shared hosting have of uploading files. It also enables people to synchronize their websites with their PC's for backup etc.. In any event if you are a website designer or just setting up a Content Management System, you will need a file transfer program. There are quite a few FTP clients or 'FTP Apps' out there, your choice will depend on your personal preference and budget. We use the handy opensource Filezilla FTP Client which, in line with the nature of open-source software, is free. In our view, it is very functional and has some quite advanced features. It is Filezilla that we use for the screenshot's and examples in this article. We assume you have already downloaded an FTP client and input the login details for your server or host.
The default interface consists of two sides. The left side represents files on the local computer, i.e your PC, whilst the right represents files on the remote server i.e. your hosting provider. The image below also shows the ability to enter a username and password for quick connection if you haven't already done so. The port can sometimes be left blank but is usually port 22 if you need to enter it.
Once you have connected to the server the right hand side of the application will populate with a list of files and folders that are on the server. You can upload your website folders to the server by browsing the local computer on the left for the relevant folder and then dragging ti over to the right hand side onto the server. Double clicking on files and folders in Filezilla also triggers the copying of the file to the other side. Please refer to the documentation for your FTP client for further explanation on how to use it.
Right clicking on a folder or file will display a contextual menu as follows:
You can see from the image of the interface that the screen is split into sections, the 'Site' section and the 'Files' section. Right Clicking on a folder in the 'Site' section will give the first menu above, whereas right clicking on a folder/file in the 'Files' section will give the second contextual menu. Choosing 'File Attributes' or 'File Permissions' will open the permissions settings window, as shown below. Choosing folders in the lower 'Files' section is less risky as you are using more fine grained settings, that is, you make changes on a folder or file by file basis. Whereas the top 'Site' section could result in you changing many sub-folders by accident, so be careful. The settings window appears as follows:
Here you can change the file permissions, but make sure you are aware of which permissions each file or folder requires. You can select the tick boxes or input a permissions value such as 644 as shown above. Ticking the 'Recurse into subdirectories' will apply the new permissions to all sub-directories and files depending on the options you choose here. You can choose only files in sub-directories, only directories/folders, or both. Again be careful with this in order to avoid any unwanted changes. By default this recursive option is not selected. So that's about all there is to it. If you want to understand a bit more about permissions, our blog article on permissions provides an explanation. Any changes you make should be done with a full understanding of the security aspects of permissions and the implications that making any changes has. As a tip, you should almost never use the permission 777 as this makes files vulnerable to changes and could cause your site/online-files to be compromised. The blog article mentioned above sets out what the numbers in the permissions matrix mean. In general, the lower the numbers assigned, the more secure the setup. Remember, your ability to make changes to permissions will depend on the privileges assigned to your username and login. For shared hosting this is normally fine, but if you want to use FTP with a VPS you will need to grant the correct privileges to the username you are using. Feel free to comment and let us have your feedback.