Chmod Chmod

Chmod - Definition and Overview

The title given to this article is incorrect due to technical limitations. The correct title is chmod.

chmod (abbreviated from change mode) is a shell command in Unix-like environments.

When executed, the command can change file system modes of files and directories. The modes include permissions and special modes.

Contents

History

A chmod command first appeared in AT&T UNIX version 1.

Usage

The chmod command options are specified like this:

chmod switches modes files

Switches

chmod has a number of command line options, or "switches", that can modify the output. Some of these options are

  • -R: recursively modify modes of all files in subdirectories.
  • -h: if the file specified is a soft link, change the mode of the link itself rather than the file that the link points to.
  • -v: verbose. List all files as they are being processed

Modes

There are permissions and special modes. The permissions are:

r - read permission;
w - write permission;
x - execute permission;

For each file is specified which permissions apply to the owner of the file, users in the group of the file, or all other users.

The modes can be specified in two ways, with characters or octal numbers. For characters, there are modification operators such that + adds the mode, = sets the mode, and - removes the mode setting.

Special Modes

There are three so called special modes as well: the sticky bit, set user ID, and set group ID.

  • 1000: If the sticky bit, set by adding octal number 1000 to the permissions, is applied to a directory, then only the file owner, the directory owner, or superuser can delete a file in that directory. For example, if a directory has permissions 0770, then the directory owner or anyone in the directory's group can add files or delete any files (regardless of who the file's owner is). If the sticky bit is set, so the permissions are 1770, then anyone in the group can add files to the directory, but each user can only delete her own files.
  • 4000: This permission sets the set user ID bit. When a directory has this permission, files created within the directory have the user ID of the directory, rather than that of the user who created the file. Note that some operating systems don't allow you to use this numerical value, instead forcing you to use the symbolic alternative.
  • 2000: This octal permission code sets the set group ID bit. When a directory has this permission, files created within the directory have the group ID of the directory, rather than that of the default group setting for the user who created the file. Note that some operating systems don't allow you to use this numerical value, instead forcing you to use the symbolic alternative.

Examples

+r 
Read is added for all;
u=rw,go= 
Read and write is set for the owner, all permissions are cleared for the group and others;
-x 
execute permission is removed for all;

In octal mode, four numbers are specified and used to set the mode of a file. For owner, group and other the value of each setting is added and the modes are concatenated. The modes are given the values r 4; w 2; x 1.

Specified as:
0755 - Equivalent to u=rwx,go=rx. The 0 specifies no special modes.

Sample use

Example:

chmod +rw file.txt

The chmod command will change the permissions of the file file.txt to read and write for all.

chmod -R u+w,go-w docs/

The chmod command will change the permissions of the directory docs and all its contents to add write access for the user, and deny write access for everybody else.

External links


Example Usage of Chmod

techplaceart: No complicated database setup and manual Chmod settings are necessary any more to create Members only private site. http://bit.ly/4vGf60
marion_w_0: @DavisonMX5 schrijfrechten voor het mapje. Heet Chmod vraag me niet waarom. Kan je via ftp programma instellen. Vaak rechtermuis->Chmod..
zach_rose: @asp actually they go in /usr/bin, but Chmod to 555 is the silver bullet i was looking for. you're still wonderful.
Copyright 2009 WordIQ.com - Privacy Policy  :: Terms of Use  :: Contact Us  :: About Us
This article is licensed under the GNU Free Documentation License. It uses material from the this Wikipedia article.