File permissions

There are a number of file permissions, which can be used for a variety of different purposes, however, we'll limit this tutorial to the ones most commonly used. To begin with, it's important you understand the three categories of permissions, which are:

Owner Permissions:
The owner is you. In most cases, this is not so much of a concern, as you can only obtain owner permissions in one of two ways. 1. FTP into your account using your Username and Password. 2. Login via Telnet with the same information. 

Group Permissions:
The represents a group of users who have access to a particular directory. For example, a password-protected directory, whereas only members can access it upon providing the correct Username and Password. In this case, any permissions you assign to "Group" would be applicable to users with access to that particular directory.

Public Permissions:
This is the most important one of all. Public permissions determine what your world wide visitors can and cannot do with your files. ALWAYS make sure you understand what particular permission does before assigning it to a file. If not, you may wake up to find your website demolished by somebody who gained access to your files.

Here's a straightforward way to check what the numbers mean.

0 No permissions whatsoever
4 Read
5 Read / execute
6 Read / write
7 Read / write / execute

To set file permissions:
These instructions should work for most popular FTP software. If not, please consult their manual.

1. Login with your FTP client
2. Locate the file you wish to change
3. Right-click on the file and select CHMOD

At this point, you should be able to select the individual permissions you want, or simply enter the 3 digit number if you know what it is. Most instructions included with downloaded scripts will tell indicate this to you.

By default, all files uploaded to the server automatically have permissions set to 644. The setting 644 is relatively safe, as it provides "Read" and "Write" access to the owner while limiting the rest of the public to "Read Only" access.

When setting permissions for cgi scripts, the most common permissions setting is 755. 755 allows the owner "Read and Write" access while allowing the Group and Public "Read and Execute" permissions. So what are we actually saying? In short, when users access your cgi script, the server has been instructed to grant them permissions to "Read and Execute" it. Sound scary? It's not actually.

Remember that a script is a program that must be processed by the server. As long as the script is written properly, you can safely allow users to execute it, and thus providing the desired results. For example, if they wanted to post a message to your wwwboard discussion forum, then they would need these permissions to execute wwwboard.pl, which would write their new message to an html file, which is displayed on the main forum. The new message would reside in a directory on your site so other users could view it. Most cgi, perl and other scripts you'll be installing come complete with instructions telling you which permissions you'll need to set them to. 

WARNING!

Setting permissions on files is a relatively simple task, however, PLEASE be sure you fully understand what it is you're allowing the public to do with your files. For example, some less experienced users often make the fatal mistake of simply setting ALL of their files or folders to 777. While 777 will automatically allow executing privileges, it also allows full "READ, WRITE, and EXECUTION ability to the entire world.

Put simply, this is how web sites get hacked. While most visitors have good intentions, all it takes is one person who snoops about your files seeking an open back door. This could result is them gaining full access to your directories, which means they can do anything from deleting your entire site, to defacing it with obscenities.

You may encounter website scripts that require a directory to be writeable by the server. Should you not be able to achieve this without resorting to 777, please contact us and we can put in place a set of permissions and ownership for a specific directory to allow it to be writeable while remaining secure.

  • 0 utilizatori au considerat informația utilă
Răspunsul a fost util?

Articole similare

Creating a simple, safe contact form

If you've ever wanted a feedback or contact form on your website, you may find the following code...

Cron jobs

A 'cron job' is an automated task that can be set up within your cPanel. This will typically be...

How do I create a custom php.ini file?

A custom php.ini file can be constructed and placed in your web account. For instance, using a...

How to change the date.timezone value in PHP?

If your PHP scripts do not show the correct time, the reason is that most probably your hosting...