Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

chmod(S)

ls(C)


 chmod(C)                      06 January 1993                       chmod(C)


 Name

    chmod - change the access permissions of a file or directory

 Syntax

    chmod [who] [+|-|=] [mode ...] file ...

    chmod mode file ...

 Description

    The chmod command changes the access permissions (or mode) of a specified
    file or directory. It is used to control file and directory access by
    users other than the super user. mode may be an expression composed of
    letters and operators (called ``symbolic mode''), or a number (called
    ``absolute mode'').

    Symbolic mode

    A chmod command using symbolic mode has the form:

       chmod [who][+|-|=][mode ...] file ...

    In place of who you can use any one, or a combination, of the following
    letters:

    a  Stands for ``all users.'' If who is not indicated on the command line,
       a is the default.

    g  Stands for ``group,'' all users who have the same group ID as the
       owner of the file or directory.

    o  Stands for ``others,'' all users on the system.

    u  Stands for ``user,'' the owner of the file or directory.

    The operators are:

    +  Adds permission.

    -  Removes permission.

    =  Assigns the indicated permission and removes all other permissions (if
       any) for that variable. If no permission is assigned, existing permis-
       sions are removed.

    Permissions are set using any combination of the following letters for
    mode:

    x  Execute (sets search permission for directories).

    r  Read.

    w  Write.

    s  Sets owner or group ID on execution of the file to that of the owner
       of the file.  The mode ``u+s'' sets the user ID bit for the file.  The
       mode ``g+s'' sets the group ID bit.  Other combinations have no
       effect.  When the group ID bit is set on a directory, all files creat-
       ed under it subsequently receive the group ID of that directory.  When
       the group ID bit is not set, files are created with the group ID of
       the creating process/user.

    t  This is known as the ``sticky bit'' (see chmod(S)).  Only the mode
       ``u+t'' sets the sticky bit.  All other combinations have no effect.
       When this bit is set on a directory, files within the directory cannot
       be removed by anyone but the owner or the super user. Only the super
       user can set the sticky bit.

    l  Mandatory locking will occur during access.

    Multiple symbolic modes may be given, separated by commas, on a single
    command line. See the following ``Examples'' section for sample permis-
    sion settings.

    Mandatory file and record locking refers to a file having locked reading
    or writing permissions while a program is accessing that file. A file
    cannot have group execution permission and be able to be locked on execu-
    tion. In addition, it is not possible to turn on the set-group-ID and
    enable a file to be locked on execution at the same time. The following
    examples show illegal uses of chmod and will generate error messages:

       chmod g+x,+l filename
       chmod g+s,+l filename


    Absolute mode

    A chmod command using absolute mode has the form:

       chmod mode filename

    where mode is an octal number constructed by combining the following
    flags using logical OR:

    4000    Set user ID on execution

    20#0    Set group ID on execution if ``#'' is 7, 5, 3, or 1; enable man-
            datory locking if ``#'' is 6, 4, 2, or 0

    1000    Sets the sticky bit (see chmod(S))

    0400    Read by owner

    0200    Write by owner

    0100    Execute (search in directory) by owner

    0040    Read by group

    0020    Write by group

    0010    Execute (search in directory) by group

    0004    Read by others

    0002    Write by others

    0001    Execute (search in directory) by others

    0000    No permissions

 Examples


    Symbolic mode

    The following command gives all users execute permission for file:

       chmod +x file


    The following command removes read and write permission for group and
    others from file:

       chmod go-rw file


    The following command gives other users read and write permission for
    file:

       chmod o+rw file


    The following command gives read permission to group and others:

       chmod g+r,o+r file


    The following example causes the mandatory locking of file on access:

       chmod +l file


    Absolute mode

    The following command gives all users read, write and execute permission
    for file:

       chmod 0777 file


    The following command gives read and write permission to all users for
    file:

       chmod 0666 file


    The following command gives read and write permission to the owner of
    file only:

       chmod 0600 file


 Limitations

    The setuid, setgid and sticky bit settings have no effect on shell
    scripts.

 See also

    chmod(S), ls(C)

 Standards conformance

    chmod is conformant with:

    AT&T SVID Issue 2;
    X/Open Portability Guide, Issue 3, 1989.


Typewritten Software • bear@typewritten.org • Edmonds, WA 98026