| |
CHMOD Setting File Permissions
![[ line ]](img/line.gif)
The chmod command in UNIX is what you use when you want to control access to a specific file for reading, writing and executing
The chmod command is similar to DOS's attrib command but goes a few steps further: UNIX allows for several users to access the same file. The different users are broken up into three categories: user, group and others. There is also a category called all, which encompasses the other three categories.
With the chmod command you specify what permissions are given to each category of users. The permissions that can be given to a file are many, the most commonly used are read, write and execute.
The permissions given are for reading, writing, and executing. They have different meanings for ordinary files and directories. Caution: It is possible for you to lock yourself out of one of your own files with chmod. Be careful when you type it.
- For an ordinary file, permissions are defined as follows:
- read . . . . . . . . . you may look at the contents of the file
- write . . . . . . . . . you may change the contents of the file or delete it
- execute . . . . . . you may execute the file as if it were a Unix command.
- For a directory, permissions are defined as follows:
- read . . . . . . . . . you may see the names of the files in the directory
- write . . . . . . . . . you may add files to and remove files from the directory
- execute . . . . . . you may change to the directory, search the directory, and copy files from it.
- The characters used to represent these permissions are:
- r . . . . . . . . . read permission
- w . . . . . . . . write permission
- x . . . . . . . . .execute permission
- - . . . . . . . . . permission denied
- Note that each permission also has a number assigned to it. The sum of these numbers determine the digits of the chmod. For example:
- 7 . . . . . can read, write and execute permissions (4 + 2 + 1)
- 6 . . . . . can read and write. (2 + 4)
- 5 . . . . . can read and execute. (4 + 1)
- 4 . . . . . can read file only
- 3 . . . . . write and execute file (2 + 1)
- 2 . . . . . can write file only
- 1 . . . . . can execute file only
- 0 . . . . . can't do anything
- So, if the permission is 755, then the owner has all permissions, and both group and other have read and execute.
| PERMISSION | COMMAND |
| User | Group | World | |
| rwx | rwx | rwx | chmod 777 |
| rwx | rwx | r-x | chmod 775 |
| rwx | r-x | r-x | chmod 755 |
| rw- | rw- | r-- | chmod 664 |
| rw- | r-- | r-- | chmod 644 |
- Some modes that are often useful in a typical CGI context are:
- CGI programs . . . . . 755
- data files to be readable by CGI . . . . . 644
- directories for data used by CGI . . . . . 755
- data files to be writable by CGI . . . . . 666 (data has absolutely no security)
- directories for data used by CGI with write access . . . . . 777 (no security)
- data files for setuid CGI programs . . . . . 600 or 644
- directories for data used by setuid CGI programs . . . . . 700 or 755
![[ line ]](img/line.gif)
[ Back to Top | Home ]
Copy & Copyright (c) 1998 - 2006 Creative Computing
Please Click To Visit Our Friends At:
|