Recent Changes - Search:

Menu

Coranto Docs

Coranto Links

PmWiki Home

chmod Explained

Definition

chmod is a Unix command for setting the permissions of a file. It is short for change mode.

If you are using a Unix or Linux server to host your website you will probably need to understand the chmod command. This command is used to tell the server who can do what with the files located there.

Permissions

WHO

There are three "whos" that a Unix server is concerned with:

  • The individual owner of the file
  • The group that owns the file
  • Every other user

Each file has an owner. If you are paying someone to host your web site it is very likely that they have set things up so that YOU are the owner of all of the files in the directories that make up you web site.

Each user in the system can belong to one or more groups. The group permissions effect anyone who belongs to the group that owns the file.

If you aren't the owner and don't belong to the group that owns the file you are just a user. Someone browsing your web site falls into this category.

↑ Contents

WHAT

There are three things you can do with a file:

  • Read it
  • Write it
  • Execute it

Reading a file means you can look at it. In the case of a visitor to your website, it usually means that they can see it in their browser.

Having write permissions on a file means that you can edit it, make changes to it, even erase it.

Execute permissions mean that the file can be run on the server. The file is executed by the server. When using a script written in PERL (like Coranto) the script file must have execute permissions or the server will not run them.

Here is the properties window for a file on this server. The window is from the FTP program Smart FTP. In Smart FTP you use this form to set file permissions. Other ftp clients use different methods, read the docs for your ftp program for details.

↑ Contents

This shows the typical chmod value of 755 for scripts. You can see the three types of users that permissions can be set for and the three types of permissions you can set. You may also see the permissions of a file expressed like this:

-rwxr-xr-x

This representation of the files permissions means exactly the same thing as 755. Her is how we get to that:

The first column is the filetype if this were a directory it would be d

The next three columns (rwx in our example above) are the owners permissions. In this case the owner can read, write, and execute the file.

The next three columns are the group's permissions (r-x in our example above). The group members can read and execute the file. The dash in the middle position means that the group does not have write permissions.

The next three columns are the permissions for all other users(r-x in our example above). Everyone else can read and execute the file, but they do not have write permissions.

The way that this translates into the 755 is that each type of permission has a value.

  • read = 4
  • write = 2
  • execute = 1

Adding up the permissions allowed for each type of user gives you the three digit equivalent of the files permissions

↑ Contents

Click on the link below to view a demo that shows the relationship between the three digit numbers and permissions shown in a listing on the server (uses javascript).

chmod Demo

For a more detailed tutorial to chmod see Dave Eisenberg's chmod Tutorial

Revision History

  • Originally published December 9, 2003
  • July 28, 2006
    • Reformatted and published to this wiki

↑ Contents

Copyright

This document copyright December 9, 2003

This document is copyrighted by the author, Dale Ray. It may be reprinted and/or reproduced for non-commercial, non-profit use only. You may not reprint and/or reproduce this document in any form for profit or for use in a venture that is operated with the intent of making a profit without the author's permission. You must leave this copyright notice intact. If you alter the content of the document you must clearly indicate the altered sections.

If you reproduce this document I ask that you contact me and let me know where and how you are using it.

No warranty, promises. or guarantees

The information in this document is accurate to the best of my knowledge. Use this information at your own risk. Make back ups and back ups of your back ups. There are no promises or guarantees of the fitness of this information for any use. There are no implied or stated warranties.

↑ Contents


You can leave comments using this form.


Edit - History - Print - Recent Changes - Search
Page last modified on December 25, 2006, at 01:50 PM