Webmaster Workshop
The Beginner's Guides Section

Front Page  Forums    Contact Us   Terms of Use   How To Guides  Resource Center


Hyperseek Search Engine
Ready to play with the big boys?


GUIDES

GENERAL

Choosing a Host

Hosting Terminology

Protection of contents


SCRIPTING

Beginners Guide to Telnet

Basic UNIX Commands

CHMOD and setting
permissions Guide

Basic guide to CRONTAB

Basic Guide to Paths

CHMOD and PERMISSIONS GUIDE

Permissions are perhaps one of the most confusing issues that confronts the newcomer to script installation.
If you are a newcomer please read and make sure you understand this guide.

One of the most frequently things causing scripts not to perform properly on installation is wrongly set permissions.

This guide will firstly set out permissions and what they do 
This applies to both using telnet or FTP to set permissions.

If you understand permission values and want a guide to chmod jump to here

FIRSTLY:   There are three types of permissions these are read write and execute.

 PERMISSION

READ

FILE

read a file

DIRECTORY

list files in

WRITE   write a file create a file in..
rename a file in..
delete a file in..
EXECUTE execute a script

( run a script )

execute a file in..
read a file in..
write a file in..
execute a script in..

SECONDLY: There are three groups of permissions user, group and world

  • User       the owner of the file

  • Group    the group to which the owner belongs

  • World    everyone else


Using FTP you are often presented with a dialogue box like below

  USER GROUP WORLD
READ
WRITE      
EXECUTE

This Means:   The user can read, write and execute this file and the group and world can just read and execute this file.


Now you will find quite often reference to setting permissions to either a number or a group of letters.
e.g. 

  •    Numbers like  755 or 777

  •    Letters like rwxr-xr-x     or rwxrwxrwx  

Firstly let's tackle the numbers

  • Read is given the value of     4

  • Write is given the value of     2

  • Execute is given the value of 1

This then is translated by adding the values together for each of the groups of permissions.

Therefore if setting permissions for the file as in the Table above

  • User can read(4), write(2) and execute(1)   i.e. 4 + 2 + 1 = 7

  • Group can read(4), and execute(1)             i.e. 4 + 0 + 1 = 5

  • World can read(4), and execute(1)             i.e. 4 + 0 + 1 = 5

Therefore the permission in this case would be 755

If the group could write as well read and execute Group would = 4+2+1 =7

Therefore the permission would be 775

IF 

  • user can read write and execute

  • group can read and write             

  • world can read and execute        

         

  USER GROUP WORLD
READ 4 4 4
WRITE   2 2  
EXECUTE 1   1
Add together the columns and your permission would be 7 6 5

SECONDLY: let's tackle the letters

Basically this is the same as the numbers but using letters instead of numbers

  • Read        = r      (4)

  • Write       = w      (2)

  • Execute   = x      (1)

So to set permission to 765  as above it would translate to

rwx rw- r-x

OR to set to 777                         rwx rwx rwx
         to set to 644                         rw- r--   r--

644 meaning owner can read and write and group and world can read only



CHMOD COMMAND

If you fully understand the above you can now move onto the chmod command.

We will start with the easier way by using numbers to set permissions

chmod  777  example.html

will set the file named example in the current directory to read write and execute for everyone

chmod  755 *.cgi

will set all the files with the extension cgi in the current directory to read write and execute for the user read and execute for the group and world.

chmod  777  directory

will set the permissions for all files and sub directories of the directory named directory to read, write and execute for everyone.


Working with letters is slightly more complicated and is detailed below.

Besides the letters relating to the permissions  r  w  x      see above click here

there is another set of letters  relating to sets of permissions

  • u    User

  • g    Group

  • o    World or Others

  • a     All the above 

Permissions are granted with the following operators

  • +    Add a permission

  • =    Assign a permission

  •     Remove a permission 

Format    chmod   usr|grp|othr  operator  permission

EXAMPLES:

chmod  ugo=rwx filename

This would assign the file filename in the current directory read write and execute permissions to the user group and others (world) (777)

chmod  u=rwx,go=rx filename

This would assign the file filename in the current directory read write and execute permission for the user and read and execute only for the group and world (755)

chmod  go= filename

This would clear all permissions for group and the world for the file filename

chmod  o-x *.cgi

This would remove execute permission for the world for all files with the extension cgi 

chmod  u=rwx,go=r directory

This would set the directory named directory and all files and subdirectories in it to user read write and execute the group and world to read only (744)

chmod  go+w directory

This would add write permission for the group and world to the directory named directory and all the files and subdirectories in it

 

Back to Unix Command Guide   Back to Guides Home Page

 


This site design and content is Copyright 2000-2005 by
Webmaster Workshop.com
Also the content supplied by other organizations is subject to their
respective Trade Marks and Copyright Policies

Webmaster