Chmod

The title of this article is incorrect because of 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 their 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

fr:Chmod pl:Chmod sv:Chmod

Navigation

  • Art and Cultures
    • Art (https://academickids.com/encyclopedia/index.php/Art)
    • Architecture (https://academickids.com/encyclopedia/index.php/Architecture)
    • Cultures (https://www.academickids.com/encyclopedia/index.php/Cultures)
    • Music (https://www.academickids.com/encyclopedia/index.php/Music)
    • Musical Instruments (http://academickids.com/encyclopedia/index.php/List_of_musical_instruments)
  • Biographies (http://www.academickids.com/encyclopedia/index.php/Biographies)
  • Clipart (http://www.academickids.com/encyclopedia/index.php/Clipart)
  • Geography (http://www.academickids.com/encyclopedia/index.php/Geography)
    • Countries of the World (http://www.academickids.com/encyclopedia/index.php/Countries)
    • Maps (http://www.academickids.com/encyclopedia/index.php/Maps)
    • Flags (http://www.academickids.com/encyclopedia/index.php/Flags)
    • Continents (http://www.academickids.com/encyclopedia/index.php/Continents)
  • History (http://www.academickids.com/encyclopedia/index.php/History)
    • Ancient Civilizations (http://www.academickids.com/encyclopedia/index.php/Ancient_Civilizations)
    • Industrial Revolution (http://www.academickids.com/encyclopedia/index.php/Industrial_Revolution)
    • Middle Ages (http://www.academickids.com/encyclopedia/index.php/Middle_Ages)
    • Prehistory (http://www.academickids.com/encyclopedia/index.php/Prehistory)
    • Renaissance (http://www.academickids.com/encyclopedia/index.php/Renaissance)
    • Timelines (http://www.academickids.com/encyclopedia/index.php/Timelines)
    • United States (http://www.academickids.com/encyclopedia/index.php/United_States)
    • Wars (http://www.academickids.com/encyclopedia/index.php/Wars)
    • World History (http://www.academickids.com/encyclopedia/index.php/History_of_the_world)
  • Human Body (http://www.academickids.com/encyclopedia/index.php/Human_Body)
  • Mathematics (http://www.academickids.com/encyclopedia/index.php/Mathematics)
  • Reference (http://www.academickids.com/encyclopedia/index.php/Reference)
  • Science (http://www.academickids.com/encyclopedia/index.php/Science)
    • Animals (http://www.academickids.com/encyclopedia/index.php/Animals)
    • Aviation (http://www.academickids.com/encyclopedia/index.php/Aviation)
    • Dinosaurs (http://www.academickids.com/encyclopedia/index.php/Dinosaurs)
    • Earth (http://www.academickids.com/encyclopedia/index.php/Earth)
    • Inventions (http://www.academickids.com/encyclopedia/index.php/Inventions)
    • Physical Science (http://www.academickids.com/encyclopedia/index.php/Physical_Science)
    • Plants (http://www.academickids.com/encyclopedia/index.php/Plants)
    • Scientists (http://www.academickids.com/encyclopedia/index.php/Scientists)
  • Social Studies (http://www.academickids.com/encyclopedia/index.php/Social_Studies)
    • Anthropology (http://www.academickids.com/encyclopedia/index.php/Anthropology)
    • Economics (http://www.academickids.com/encyclopedia/index.php/Economics)
    • Government (http://www.academickids.com/encyclopedia/index.php/Government)
    • Religion (http://www.academickids.com/encyclopedia/index.php/Religion)
    • Holidays (http://www.academickids.com/encyclopedia/index.php/Holidays)
  • Space and Astronomy
    • Solar System (http://www.academickids.com/encyclopedia/index.php/Solar_System)
    • Planets (http://www.academickids.com/encyclopedia/index.php/Planets)
  • Sports (http://www.academickids.com/encyclopedia/index.php/Sports)
  • Timelines (http://www.academickids.com/encyclopedia/index.php/Timelines)
  • Weather (http://www.academickids.com/encyclopedia/index.php/Weather)
  • US States (http://www.academickids.com/encyclopedia/index.php/US_States)

Information

  • Home Page (http://academickids.com/encyclopedia/index.php)
  • Contact Us (http://www.academickids.com/encyclopedia/index.php/Contactus)

  • Clip Art (http://classroomclipart.com)
Toolbox
Personal tools