Webmonkey
Powered by Atomz.com



Quick Reference:

Javascript Code Library
HTML Cheatsheet
Special Characters
Color Codes
Browser Chart
Stylesheet Guide
• Unix Guide
Glossary
Domain Registries

Reference   Unix Guide

chmod/permissions

chmod (which stands for "change mode") changes who can access a particular file. A "mode" is created by combining the various options from who, opcode, and permission.

Structure: chmod [option] mode file

If you look at a list of files using the long list format ls -l, you'll see the permissions, owner, file size, modification time, and filename. The first column of the list shows who can read, write, and execute the files or directories - in other words, the permissions. It basically shows who has permission to do what to a given file or directory. r stands for "read" and means that you're allowed to read the file or directory. w stands for "write" and gives permission to edit or change the file as well as create, move, rename, or remove a directory. x stands for "execute," which gives permission to run a file or search a directory.

Every file or directory has four sets of rwx permissions. The first set represents the user (u), the second set represents the group (g), the third set represents other (o), and the fourth set represents all (a). The column will look like this:

rwxrwxrwx

Each set of rwx represents user, group, and other respectively. Only the owner of a file or a privileged user may change the permissions on a file.

There are two ways to change permissions on a file or directory, either numerically or by using lettered commands. Both ways use the command chmod. To add permissions to a file, you use +, to remove permissions you use-. Take this file for example:

-rw-r--r-- 1 meghan monkey 476 Oct 14 17:13 simian.html
To allow a group (monkey, in this case) "write" access, you would type:
chmod g+w simian.html

If you wanted to remove "read" ability from "other" you would type:

chmod o-r simian.html

It is also possible to specify permissions using a three-digit sequence. This is a more efficient way to change permissions (or at least it requires less typing), so use this method if it doesn't confuse you. Each type of permission is given an octal value. Read is given the value of 4, write is given the value of 2, and execute is given the value of 1. These values are added together for each user category. The permissions are changed by using a three-digit sequence with the first digit representing owner permission, the second digit representing group permission, and the third digit representing other permission. For example, if you wanted to make simian.html readable, writable, and executable for the user, readable and writable for the group, and readable for other, you would type:

chmod 764 simian.html

The first digit means readable and writable for the user (4+2+1), the second digit means readable and writable for the group (4+2), and the third digit means readable for other (4).

If you want to change the permissions on a directory tree use the -R option. chmod -R will recursively change the permissions of directories and their contents.

Back to the index.



Feedback  |  Help  |  About Us  |  Contribute  |  Jobs
Advertise  |  Privacy Statement  |  Terms and Conditions

Copyright © 1994-2000 Wired Digital Inc., a Lycos Network site. All rights reserved.