Modes (Unix)

Modes (Unix)

See also: Symbolic notation of file system permissions

Modes are the permissions given to users, groups and/or the 'other' class to access files.

Modes are shown when listing files in long format, or, if Access Control Lists are in use, using getfacl.

Modes can be changed with chmod (for older Unix permissions) or with setfacl (for Access Control Lists).

For traditional Unix permissions, the symbolic mode is composed of three components, which are combined to form a single string of text:

$ chmod [references][operator][modes] file1 ...

The references (or classes) are used to distinguish the users to whom the permissions apply. If no references are specified it defaults to "all". They are represented by one or more of the following letters:

Reference Class Description
u user the owner of the file
g group users who are members of the file's group
o others users who are not the owner of the file or members of the group
a all all three of the above, is the same as ugo

The chmod program uses an operator to specify how the modes of a file should be adjusted. The following operators are accepted:

Operator Description
+ adds the specified modes to the specified classes
- removes the specified modes from the specified classes
= the modes specified are to be made the exact modes for the specified classes

The modes indicate which permissions are to be granted or taken away from the specified classes. There are three basic modes which correspond to the basic permissions:

Mode Name Description
r read read a file or list a directory's contents
w write write to a file or directory
x execute execute a file or recurse a directory tree
X special execute which is not a permission in itself but rather can be used instead of x. It applies execute permissions to directories regardless of their current permissions and applies execute permissions to a file which already has at least 1 execute permission bit already set (either user, group or other). It is only really useful when used with '+' and usually in combination with the -R option for giving group or other access to a big directory tree without setting execute permission on normal files (such as text files), which would normally happen if you just used "chmod -R a+rx .", whereas with 'X' you can do "chmod -R a+rX ." instead
s setuid/gid details in Special modes section
t sticky details in Special modes section

The combination of these three components produces a string that is understood by the chmod command. Multiple changes can be specified by separating multiple symbolic modes with commas.

String mode examples

For example, the following command would be used to add the read and write permissions to the user and group classes of a file or directory named sample:

$ chmod ug+rw sample
$ ls -ld sample
drw-rw----   2 unixguy  unixguy       96 Dec  8 12:53 sample

This command removes all permissions, allowing no one to read, write, or execute the file named sample.

$ chmod a-rwx sample
$ ls -l sample
----------   2 unixguy  unixguy       96 Dec  8 12:53 sample

The following command changes the permissions for the user and the group to read and execute only (no write permission) on sample.

Sample file permissions before command
$ ls -ld sample
drw-rw----   2 unixguy  unixguy       96 Dec  8 12:53 sample
$ chmod ug=rx sample
$ ls -ld sample
dr-xr-x---   2 unixguy  unixguy       96 Dec  8 12:53 sample

Wikimedia Foundation. 2010.

Игры ⚽ Поможем написать реферат

Look at other dictionaries:

  • Unix-like — Diagram of the relationships between the major Unix like systems A Unix like (sometimes referred to as UN*X or *nix) operating system is one that behaves in a manner similar to a Unix system, while not necessarily conforming to or being certified …   Wikipedia

  • Chmod (Unix) — chmod Capture d écran de la page de manuel en anglais de la commande chmod chmod (abréviation de change mode) est une commande Unix exécutable dans un environnement de type Unix qui permet de changer les permissions d accès (spéciales ou non) sur …   Wikipédia en Français

  • Vi (Unix) — vi Pour les articles homonymes, voir VI. vi est un éditeur de texte en mode texte plein écran écrit par Bill Joy en 1976 sur une des premières versions de la distribution Unix BSD. Il est présent d office sur la majorité des systèmes Unix actuels …   Wikipédia en Français

  • Vi (unix) — vi Pour les articles homonymes, voir VI. vi est un éditeur de texte en mode texte plein écran écrit par Bill Joy en 1976 sur une des premières versions de la distribution Unix BSD. Il est présent d office sur la majorité des systèmes Unix actuels …   Wikipédia en Français

  • List of Unix utilities — This is a list of UNIX utilities as specified by IEEE Std 1003.1 2008, which is part of the Single UNIX Specification (SUS). These utilities can be found on UNIX Operating systems and most UNIX like operating systems. List IEEE Std 1003.1 2008… …   Wikipedia

  • crypt (Unix) — In Unix computing, crypt is the name of both a utility program and a C programming function. Though both are used for encrypting data, they are otherwise essentially unrelated. To distinguish between the two, writers often refer to the utility… …   Wikipedia

  • Commande UNIX — Commandes Unix Les systèmes d exploitation de type UNIX offrent à leurs utilisateurs des centaines de commandes qui font de la console un outil pratique et extrêmement puissant. Certaines d entre elles sont fournies directement par le shell,… …   Wikipédia en Français

  • Commande Unix — Commandes Unix Les systèmes d exploitation de type UNIX offrent à leurs utilisateurs des centaines de commandes qui font de la console un outil pratique et extrêmement puissant. Certaines d entre elles sont fournies directement par le shell,… …   Wikipédia en Français

  • Commandes UNIX — Les systèmes d exploitation de type UNIX offrent à leurs utilisateurs des centaines de commandes qui font de la console un outil pratique et extrêmement puissant. Certaines d entre elles sont fournies directement par le shell, alors que d autres… …   Wikipédia en Français

  • Commandes Unix — Les systèmes d exploitation de type UNIX offrent à leurs utilisateurs des centaines de commandes qui font de la console un outil pratique et extrêmement puissant. Certaines d entre elles sont fournies directement par le shell, alors que d autres… …   Wikipédia en Français

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”