icon Top 9 categories map      RocketAware >

chmod(1)

Tips: Browse or Search all pages for efficient awareness of more than 6000 of the most popular reusable and open source applications, functions, libraries, and FAQs.


The "RKT couplings" below include links to source code, updates, additional information, advice, FAQs, and overviews.


Home

Search all pages


Subjects

By activity
Professions, Sciences, Humanities, Business, ...

User Interface
Text-based, GUI, Audio, Video, Keyboards, Mouse, Images,...

Text Strings
Conversions, tests, processing, manipulation,...

Math
Integer, Floating point, Matrix, Statistics, Boolean, ...

Processing
Algorithms, Memory, Process control, Debugging, ...

Stored Data
Data storage, Integrity, Encryption, Compression, ...

Communications
Networks, protocols, Interprocess, Remote, Client Server, ...

Hard World
Timing, Calendar and Clock, Audio, Video, Printer, Controls...

File System
Management, Filtering, File & Directory access, Viewers, ...

    

RocketLink!--> Man page versions: OpenBSD FreeBSD NetBSD RedHat Others

[IEEE Std1003.2-1992 (``POSIX.2'')]

CHMOD(1)                   OpenBSD Reference Manual                   CHMOD(1)

NAME
     chmod - change file modes



SYNOPSIS
     chmod [-R [-H | -L | -P]] mode [file ...]

DESCRIPTION
     The chmod utility modifies the file mode bits of the listed files as
     specified by the mode operand. The mode of a file dictates its permis-
     sions, among other attributes.

     The options are as follows:

     -R      Recursively descend through any specified directory arguments.
             Change the modes of the file hierarchies rooted in the files in-
             stead of just the files themselves.

     -H      If the -R option is also specified, symbolic links on the command
             line are followed.  (Symbolic links encountered in the tree
             traversal are not followed.)

     -L      If the -R option is also specified, all symbolic links are fol-
             lowed.

     -P      If the -R option is also specified, no symbolic links are fol-
             lowed.

     Symbolic links do not have modes, so unless the -H or -L option is set,
     chmod on a symbolic link always succeeds and has no effect.  The -H, -L,
     and -P options are ignored unless the -R option is specified.  In addi-
     tion, these options override each other and the command's actions are de-
     termined by the last one specified.

     Only the owner of a file or the super-user is permitted to change the
     mode of a file.

     The chmod utility exits 0 on success or >0 if an error occurred.

   Absolute modes
     Absolute modes are specified according to the following format:

           chmod nnnn file [...]

     An absolute mode is an octal number (specified as nnnn, where n is a num-
     ber from 0 to 7) constructed by ORing any of the following values:

           0400    Allow read by owner.
           0200    Allow write by owner.
           0100    Allow execution (or search in directories) by owner.
           0700    Allow read, write, and execute/search by owner.
           0040    Allow read by group.
           0020    Allow write by group.
           0010    Allow execution (or search in directories) by group.
           0070    Allow read, write, and execute/search by group.
           0004    Allow read by others.
           0002    Allow write by others.
           0001    Allow execution (or search in directories) by others.
           0007    Allow read, write, and execute/search by others.

     In addition to the file permission modes, the following mode bits are
     available:



           4000    Set-user-ID on execution.
           2000    Set-group-ID on execution.
           1000    Enable sticky bit; see sticky(8) and chmod(2).

     The execute bit for a directory is often referred to as the ``search''
     bit. In order to access a file, a user must have execute permission in
     each directory leading up to it in the filesystem hierarchy. For example,
     to access the file /bin/ls, execute permission is needed on /, /bin, and,
     of course, the ls binary itself.

   Symbolic modes
     Symbolic modes are specified according to the following format:

           chmod <[who]op[perm]>,[[who]op[perm]],[...] file [...]

     The who symbols indicate whose permissions are to be changed or assigned:

           u     User (owner) permissions.
           g     Group permissions.
           o     Others permissions.
           a     All of the above.

     Do not confuse the `o' symbol with ``owner''. It is the user bit, `u',
     that refers to the owner of the file.

     The op symbols represent the operation performed, as follows:

           +     If no value is supplied for perm, the `+' operation has no
                 effect.  If no value is supplied for who, each permission bit
                 specified in perm, for which the corresponding bit in the
                 file mode creation mask is clear, is set.  Otherwise, the
                 mode bits represented by the specified who and perm values
                 are set.

           -     If no value is supplied for perm, the `-' operation has no
                 effect.  If no value is supplied for who, each permission bit
                 specified in perm, for which the corresponding bit in the
                 file mode creation mask is clear, is cleared.  Otherwise, the
                 mode bits represented by the specified who and perm values
                 are cleared.

           =     The mode bits specified by the who value are cleared, or, if
                 no who value is specified, the user, group and other mode
                 bits are cleared.  Then, if no value is supplied for who,
                 each permission bit specified in perm, for which the corre-
                 sponding bit in the file mode creation mask is clear, is set.
                 Otherwise, the mode bits represented by the specified who and
                 perm values are set.

     The perm (permission symbols) represent the portions of the mode bits as
     follows:

           r       Read bits.
           s       Set-user-ID and set-group-ID on execution bits.
           t       Sticky bit.
           w       Write bits.
           x       Execute/search bits.
           X       The execute/search bits if the file is a directory or any
                   of the execute/search bits are set in the original (unmodi-
                   fied) mode.  Operations with the perm symbol `X' are only
                   meaningful in conjunction with the op symbol `+', and are
                   ignored in all other cases.
           u       User permission bits in the mode of the original file.


           g       Group permission bits in the mode of the original file.
           o       Other permission bits in the mode of the original file.

     Each clause (given in a comma-delimited list on the command line) speci-
     fies one or more operations to be performed on the mode bits, and each
     operation is applied in the order specified.

     Operations upon the ``other'' permissions (specified by the symbol `o' by
     itself), in combination with the perm symbols `s' or `t', are ignored.

EXAMPLES
     Make a file readable by anyone and writable by the owner only.

           chmod 644 file

     Deny write permission to group and others.

           chmod go-w file

     Set the read and write permissions to the usual defaults, but retain any
     execute permissions that are currently set.

           chmod =rw,+X file

     Make a directory or file searchable/executable by everyone if it is al-
     ready searchable/executable by anyone.

           chmod +X file

     Any of the following will make a file readable/executable by everyone and
     writable by the owner only.

           chmod 755 file
           chmod u=rwx,go=rx file
           chmod u=rwx,go=u-w file

     Clear all mode bits for group and others.

           chmod go= file

     Set the group bits equal to the user bits, but clear the group write bit.

           chmod g=u-w file

SEE ALSO
     chgrp(1),  find(1),  install(1),  chmod(2),  stat(2),  umask(2),  fts(3),
      setmode(3),  symlink(7),  chown(8),  sticky(8)

STANDARDS
     The chmod utility is expected to be IEEE Std1003.2 (``POSIX.2'') compati-
     ble with the exception of the perm symbols `t' and `X' which are not in-
     cluded in that standard.

BUGS
     There's no perm option for the naughty bits.

OpenBSD 2.6                     March 31, 1994                               3

Source: OpenBSD 2.6 man pages. Copyright: Portions are copyrighted by BERKELEY
SOFTWARE DESIGN, INC., The Regents of the University of California, Massachusetts
Institute of Technology, Free Software Foundation, FreeBSD Inc., and others.



(Corrections, notes, and links courtesy of RocketAware.com)


[Detailed Topics]
FreeBSD Sources for chmod(1)
OpenBSD sources for chmod(1)


[Overview Topics]

Up to: File Information - Obtaining file information (status, configuration, et al)


RocketLink!--> Man page versions: OpenBSD FreeBSD NetBSD RedHat Others

[IEEE Std1003.2-1992 (``POSIX.2'')]




Rapid-Links: Search | About | Comments | Submit Path: RocketAware > chmod.1/
RocketAware.com is a service of Mib Software
Copyright 1999, Forrest J. Cavalier III. All Rights Reserved.
We welcome submissions and comments