Blame man-pages-posix-2013-a/man1p/chmod.1p

Packit 7cfc04
'\" et
Packit 7cfc04
.TH CHMOD "1P" 2013 "IEEE/The Open Group" "POSIX Programmer's Manual"
Packit 7cfc04
.SH PROLOG
Packit 7cfc04
This manual page is part of the POSIX Programmer's Manual.
Packit 7cfc04
The Linux implementation of this interface may differ (consult
Packit 7cfc04
the corresponding Linux manual page for details of Linux behavior),
Packit 7cfc04
or the interface may not be implemented on Linux.
Packit 7cfc04
Packit 7cfc04
.SH NAME
Packit 7cfc04
chmod
Packit 7cfc04
\(em change the file modes
Packit 7cfc04
.SH SYNOPSIS
Packit 7cfc04
.LP
Packit 7cfc04
.nf
Packit 7cfc04
chmod \fB[\fR\(miR\fB] \fImode file\fR...
Packit 7cfc04
.fi
Packit 7cfc04
.SH DESCRIPTION
Packit 7cfc04
The
Packit 7cfc04
.IR chmod
Packit 7cfc04
utility shall change any or all of the file mode bits of the file named
Packit 7cfc04
by each
Packit 7cfc04
.IR file
Packit 7cfc04
operand in the way specified by the
Packit 7cfc04
.IR mode
Packit 7cfc04
operand.
Packit 7cfc04
.P
Packit 7cfc04
It is implementation-defined whether and how the
Packit 7cfc04
.IR chmod
Packit 7cfc04
utility affects any alternate or additional file access control
Packit 7cfc04
mechanism (see the Base Definitions volume of POSIX.1\(hy2008,
Packit 7cfc04
.IR "Section 4.4" ", " "File Access Permissions")
Packit 7cfc04
being used for the specified file.
Packit 7cfc04
.P
Packit 7cfc04
Only a process whose effective user ID matches the user ID of the file,
Packit 7cfc04
or a process with appropriate privileges, shall be permitted to
Packit 7cfc04
change the file mode bits of a file.
Packit 7cfc04
.P
Packit 7cfc04
Upon successfully changing the file mode bits of a file, the
Packit 7cfc04
.IR chmod
Packit 7cfc04
utility shall mark for update the last file status change timestamp
Packit 7cfc04
of the file.
Packit 7cfc04
.SH OPTIONS
Packit 7cfc04
The
Packit 7cfc04
.IR chmod
Packit 7cfc04
utility shall conform to the Base Definitions volume of POSIX.1\(hy2008,
Packit 7cfc04
.IR "Section 12.2" ", " "Utility Syntax Guidelines".
Packit 7cfc04
.P
Packit 7cfc04
The following option shall be supported:
Packit 7cfc04
.IP "\fB\(miR\fP" 10
Packit 7cfc04
Recursively change file mode bits. For each
Packit 7cfc04
.IR file
Packit 7cfc04
operand that names a directory,
Packit 7cfc04
.IR chmod
Packit 7cfc04
shall change the file mode bits of the directory and all files in the
Packit 7cfc04
file hierarchy below it.
Packit 7cfc04
.SH OPERANDS
Packit 7cfc04
The following operands shall be supported:
Packit 7cfc04
.IP "\fImode\fR" 10
Packit 7cfc04
Represents the change to be made to the file mode bits of each
Packit 7cfc04
file named by one of the
Packit 7cfc04
.IR file
Packit 7cfc04
operands; see the EXTENDED DESCRIPTION section.
Packit 7cfc04
.IP "\fIfile\fR" 10
Packit 7cfc04
A pathname of a file whose file mode bits shall be modified.
Packit 7cfc04
.SH STDIN
Packit 7cfc04
Not used.
Packit 7cfc04
.SH "INPUT FILES"
Packit 7cfc04
None.
Packit 7cfc04
.SH "ENVIRONMENT VARIABLES"
Packit 7cfc04
The following environment variables shall affect the execution of
Packit 7cfc04
.IR chmod :
Packit 7cfc04
.IP "\fILANG\fP" 10
Packit 7cfc04
Provide a default value for the internationalization variables that are
Packit 7cfc04
unset or null. (See the Base Definitions volume of POSIX.1\(hy2008,
Packit 7cfc04
.IR "Section 8.2" ", " "Internationalization Variables"
Packit 7cfc04
for the precedence of internationalization variables used to determine
Packit 7cfc04
the values of locale categories.)
Packit 7cfc04
.IP "\fILC_ALL\fP" 10
Packit 7cfc04
If set to a non-empty string value, override the values of all the
Packit 7cfc04
other internationalization variables.
Packit 7cfc04
.IP "\fILC_CTYPE\fP" 10
Packit 7cfc04
Determine the locale for the interpretation of sequences of bytes of
Packit 7cfc04
text data as characters (for example, single-byte as opposed to
Packit 7cfc04
multi-byte characters in arguments).
Packit 7cfc04
.IP "\fILC_MESSAGES\fP" 10
Packit 7cfc04
.br
Packit 7cfc04
Determine the locale that should be used to affect the format and
Packit 7cfc04
contents of diagnostic messages written to standard error.
Packit 7cfc04
.IP "\fINLSPATH\fP" 10
Packit 7cfc04
Determine the location of message catalogs for the processing of
Packit 7cfc04
.IR LC_MESSAGES .
Packit 7cfc04
.SH "ASYNCHRONOUS EVENTS"
Packit 7cfc04
Default.
Packit 7cfc04
.SH STDOUT
Packit 7cfc04
Not used.
Packit 7cfc04
.SH STDERR
Packit 7cfc04
The standard error shall be used only for diagnostic messages.
Packit 7cfc04
.SH "OUTPUT FILES"
Packit 7cfc04
None.
Packit 7cfc04
.SH "EXTENDED DESCRIPTION"
Packit 7cfc04
The
Packit 7cfc04
.IR mode
Packit 7cfc04
operand shall be either a
Packit 7cfc04
.IR symbolic_mode
Packit 7cfc04
expression or a non-negative octal integer. The
Packit 7cfc04
.IR symbolic_mode
Packit 7cfc04
form is described by the grammar later in this section.
Packit 7cfc04
.P
Packit 7cfc04
Each
Packit 7cfc04
.BR clause
Packit 7cfc04
shall specify an operation to be performed on the current file mode
Packit 7cfc04
bits of each
Packit 7cfc04
.IR file .
Packit 7cfc04
The operations shall be performed on each
Packit 7cfc04
.IR file
Packit 7cfc04
in the order in which the
Packit 7cfc04
.BR clause s
Packit 7cfc04
are specified.
Packit 7cfc04
.P
Packit 7cfc04
The
Packit 7cfc04
.BR who
Packit 7cfc04
symbols
Packit 7cfc04
.BR u ,
Packit 7cfc04
.BR g ,
Packit 7cfc04
and
Packit 7cfc04
.BR o
Packit 7cfc04
shall specify the
Packit 7cfc04
.IR user ,
Packit 7cfc04
.IR group ,
Packit 7cfc04
and
Packit 7cfc04
.IR other
Packit 7cfc04
parts of the file mode bits, respectively. A
Packit 7cfc04
.BR who
Packit 7cfc04
consisting of the symbol
Packit 7cfc04
.BR a
Packit 7cfc04
shall be equivalent to
Packit 7cfc04
.BR ugo .
Packit 7cfc04
.P
Packit 7cfc04
The
Packit 7cfc04
.BR perm
Packit 7cfc04
symbols
Packit 7cfc04
.BR r ,
Packit 7cfc04
.BR w ,
Packit 7cfc04
and
Packit 7cfc04
.BR x
Packit 7cfc04
represent the
Packit 7cfc04
.IR read ,
Packit 7cfc04
.IR write ,
Packit 7cfc04
and
Packit 7cfc04
.IR execute /\c
Packit 7cfc04
.IR search
Packit 7cfc04
portions of file mode bits, respectively. The
Packit 7cfc04
.BR perm
Packit 7cfc04
symbol
Packit 7cfc04
.BR s
Packit 7cfc04
shall represent the
Packit 7cfc04
.IR "set-user-ID-on-execution"
Packit 7cfc04
(when
Packit 7cfc04
.BR who
Packit 7cfc04
contains or implies
Packit 7cfc04
.BR u )
Packit 7cfc04
and
Packit 7cfc04
.IR "set-group-ID-on-execution"
Packit 7cfc04
(when
Packit 7cfc04
.BR who
Packit 7cfc04
contains or implies
Packit 7cfc04
.BR g )
Packit 7cfc04
bits.
Packit 7cfc04
.P
Packit 7cfc04
The
Packit 7cfc04
.BR perm
Packit 7cfc04
symbol
Packit 7cfc04
.BR X
Packit 7cfc04
shall represent the execute/search portion of the file mode bits if the
Packit 7cfc04
file is a directory or if the current (unmodified) file mode bits have
Packit 7cfc04
at least one of the execute bits (S_IXUSR, S_IXGRP, or S_IXOTH) set. It
Packit 7cfc04
shall be ignored if the file is not a directory and none of the execute
Packit 7cfc04
bits are set in the current file mode bits.
Packit 7cfc04
.P
Packit 7cfc04
The
Packit 7cfc04
.BR permcopy
Packit 7cfc04
symbols
Packit 7cfc04
.BR u ,
Packit 7cfc04
.BR g ,
Packit 7cfc04
and
Packit 7cfc04
.BR o
Packit 7cfc04
shall represent the current permissions associated with the user,
Packit 7cfc04
group, and other parts of the file mode bits, respectively. For the
Packit 7cfc04
remainder of this section,
Packit 7cfc04
.BR perm
Packit 7cfc04
refers to the non-terminals
Packit 7cfc04
.BR perm
Packit 7cfc04
and
Packit 7cfc04
.BR permcopy
Packit 7cfc04
in the grammar.
Packit 7cfc04
.P
Packit 7cfc04
If multiple
Packit 7cfc04
.BR actionlist s
Packit 7cfc04
are grouped with a single
Packit 7cfc04
.BR wholist
Packit 7cfc04
in the grammar, each
Packit 7cfc04
.BR actionlist
Packit 7cfc04
shall be applied in the order specified with that
Packit 7cfc04
.BR wholist .
Packit 7cfc04
The
Packit 7cfc04
.IR op
Packit 7cfc04
symbols shall represent the operation performed, as follows:
Packit 7cfc04
.IP "\fR+\fP" 6
Packit 7cfc04
If
Packit 7cfc04
.BR perm
Packit 7cfc04
is not specified, the
Packit 7cfc04
.BR '\(pl' 
Packit 7cfc04
operation shall not change the file mode bits.
Packit 7cfc04
.RS 6 
Packit 7cfc04
.P
Packit 7cfc04
If
Packit 7cfc04
.BR who
Packit 7cfc04
is not specified, the file mode bits represented by
Packit 7cfc04
.BR perm
Packit 7cfc04
for the owner, group, and other permissions, except for those with
Packit 7cfc04
corresponding bits in the file mode creation mask of the invoking
Packit 7cfc04
process, shall be set.
Packit 7cfc04
.P
Packit 7cfc04
Otherwise, the file mode bits represented by the specified
Packit 7cfc04
.BR who
Packit 7cfc04
and
Packit 7cfc04
.BR perm
Packit 7cfc04
values shall be set.
Packit 7cfc04
.RE
Packit 7cfc04
.IP "\fR\(mi\fP" 6
Packit 7cfc04
If
Packit 7cfc04
.BR perm
Packit 7cfc04
is not specified, the
Packit 7cfc04
.BR '\(mi' 
Packit 7cfc04
operation shall not change the file mode bits.
Packit 7cfc04
.RS 6 
Packit 7cfc04
.P
Packit 7cfc04
If
Packit 7cfc04
.BR who
Packit 7cfc04
is not specified, the file mode bits represented by
Packit 7cfc04
.BR perm
Packit 7cfc04
for the owner, group, and other permissions, except for those with
Packit 7cfc04
corresponding bits in the file mode creation mask of the invoking
Packit 7cfc04
process, shall be cleared.
Packit 7cfc04
.P
Packit 7cfc04
Otherwise, the file mode bits represented by the specified
Packit 7cfc04
.BR who
Packit 7cfc04
and
Packit 7cfc04
.BR perm
Packit 7cfc04
values shall be cleared.
Packit 7cfc04
.RE
Packit 7cfc04
.IP "\fR=\fP" 6
Packit 7cfc04
Clear the file mode bits specified by the
Packit 7cfc04
.BR who
Packit 7cfc04
value, or, if no
Packit 7cfc04
.BR who
Packit 7cfc04
value is specified, all of the file mode bits specified in this volume of POSIX.1\(hy2008.
Packit 7cfc04
.RS 6 
Packit 7cfc04
.P
Packit 7cfc04
If
Packit 7cfc04
.BR perm
Packit 7cfc04
is not specified, the
Packit 7cfc04
.BR '=' 
Packit 7cfc04
operation shall make no further modifications to the file mode bits.
Packit 7cfc04
.P
Packit 7cfc04
If
Packit 7cfc04
.BR who
Packit 7cfc04
is not specified, the file mode bits represented by
Packit 7cfc04
.BR perm
Packit 7cfc04
for the owner, group, and other permissions, except for those with
Packit 7cfc04
corresponding bits in the file mode creation mask of the invoking
Packit 7cfc04
process, shall be set.
Packit 7cfc04
.P
Packit 7cfc04
Otherwise, the file mode bits represented by the specified
Packit 7cfc04
.BR who
Packit 7cfc04
and
Packit 7cfc04
.BR perm
Packit 7cfc04
values shall be set.
Packit 7cfc04
.RE
Packit 7cfc04
.P
Packit 7cfc04
When using the symbolic mode form on a regular file, it is
Packit 7cfc04
implementation-defined whether or not:
Packit 7cfc04
.IP " *" 4
Packit 7cfc04
Requests to set the set-user-ID-on-execution or
Packit 7cfc04
set-group-ID-on-execution bit when all execute bits are currently clear
Packit 7cfc04
and none are being set are ignored.
Packit 7cfc04
.IP " *" 4
Packit 7cfc04
Requests to clear all execute bits also clear the
Packit 7cfc04
set-user-ID-on-execution and set-group-ID-on-execution bits.
Packit 7cfc04
.IP " *" 4
Packit 7cfc04
Requests to clear the set-user-ID-on-execution or
Packit 7cfc04
set-group-ID-on-execution bits when all execute bits are currently
Packit 7cfc04
clear are ignored. However, if the command
Packit 7cfc04
.IR ls
Packit 7cfc04
.BR \(mil
Packit 7cfc04
.IR file
Packit 7cfc04
writes an
Packit 7cfc04
.IR s
Packit 7cfc04
in the position indicating that the set-user-ID-on-execution or
Packit 7cfc04
set-group-ID-on-execution is set, the commands
Packit 7cfc04
.IR chmod
Packit 7cfc04
.BR u\(mis
Packit 7cfc04
.IR file
Packit 7cfc04
or
Packit 7cfc04
.IR chmod
Packit 7cfc04
.BR g\(mis
Packit 7cfc04
.IR file ,
Packit 7cfc04
respectively, shall not be ignored.
Packit 7cfc04
.P
Packit 7cfc04
When using the symbolic mode form on other file types, it is
Packit 7cfc04
implementation-defined whether or not requests to set or clear the
Packit 7cfc04
set-user-ID-on-execution or set-group-ID-on-execution bits are
Packit 7cfc04
honored.
Packit 7cfc04
.P
Packit 7cfc04
If the
Packit 7cfc04
.BR who
Packit 7cfc04
symbol
Packit 7cfc04
.BR o
Packit 7cfc04
is used in conjunction with the
Packit 7cfc04
.BR perm
Packit 7cfc04
symbol
Packit 7cfc04
.BR s
Packit 7cfc04
with no other
Packit 7cfc04
.BR who
Packit 7cfc04
symbols being specified, the set-user-ID-on-execution and
Packit 7cfc04
set-group-ID-on-execution bits shall not be modified. It shall not be
Packit 7cfc04
an error to specify the
Packit 7cfc04
.BR who
Packit 7cfc04
symbol
Packit 7cfc04
.BR o
Packit 7cfc04
in conjunction with the
Packit 7cfc04
.BR perm
Packit 7cfc04
symbol
Packit 7cfc04
.BR s .
Packit 7cfc04
.P
Packit 7cfc04
The
Packit 7cfc04
.BR perm
Packit 7cfc04
symbol
Packit 7cfc04
.BR t
Packit 7cfc04
shall specify the S_ISVTX bit. When used with a file of type
Packit 7cfc04
directory, it can be used with the
Packit 7cfc04
.BR who
Packit 7cfc04
symbol
Packit 7cfc04
.BR a ,
Packit 7cfc04
or with no
Packit 7cfc04
.BR who
Packit 7cfc04
symbol. It shall not be an error to specify a
Packit 7cfc04
.BR who
Packit 7cfc04
symbol of
Packit 7cfc04
.BR u ,
Packit 7cfc04
.BR g ,
Packit 7cfc04
or
Packit 7cfc04
.BR o
Packit 7cfc04
in conjunction with the
Packit 7cfc04
.BR perm
Packit 7cfc04
symbol
Packit 7cfc04
.BR t ,
Packit 7cfc04
but the meaning of these combinations is unspecified. The effect when
Packit 7cfc04
using the
Packit 7cfc04
.BR perm
Packit 7cfc04
symbol
Packit 7cfc04
.BR t
Packit 7cfc04
with any file type other than directory is unspecified.
Packit 7cfc04
.P
Packit 7cfc04
For an octal integer
Packit 7cfc04
.IR mode
Packit 7cfc04
operand, the file mode bits shall be set absolutely.
Packit 7cfc04
.P
Packit 7cfc04
For each bit set in the octal number, the corresponding file permission
Packit 7cfc04
bit shown in the following table shall be set; all other file
Packit 7cfc04
permission bits shall be cleared. For regular files, for each bit set
Packit 7cfc04
in the octal number corresponding to the set-user-ID-on-execution or
Packit 7cfc04
the set-group-ID-on-execution, bits shown in the following table shall
Packit 7cfc04
be set; if these bits are not set in the octal number, they are
Packit 7cfc04
cleared. For other file types, it is implementation-defined whether
Packit 7cfc04
or not requests to set or clear the set-user-ID-on-execution or
Packit 7cfc04
set-group-ID-on-execution bits are honored.
Packit 7cfc04
.TS
Packit 7cfc04
center tab(@) box;
Packit 7cfc04
cB cB | cB cB | cB cB | cB cB
Packit 7cfc04
nB l | nB l | nB l | nB l.
Packit 7cfc04
Octal@Mode Bit@Octal@Mode Bit@Octal@Mode Bit@Octal@Mode Bit
Packit 7cfc04
_
Packit 7cfc04
4000@S_ISUID@0400@S_IRUSR@0040@S_IRGRP@0004@S_IROTH
Packit 7cfc04
_
Packit 7cfc04
2000@S_ISGID@0200@S_IWUSR@0020@S_IWGRP@0002@S_IWOTH
Packit 7cfc04
_
Packit 7cfc04
1000@S_ISVTX@0100@S_IXUSR@0010@S_IXGRP@0001@S_IXOTH
Packit 7cfc04
.TE
Packit 7cfc04
.P
Packit 7cfc04
When bits are set in the octal number other than those listed in the
Packit 7cfc04
table above, the behavior is unspecified.
Packit 7cfc04
.SS "Grammar for chmod"
Packit 7cfc04
.P
Packit 7cfc04
The grammar and lexical conventions in this section describe the syntax
Packit 7cfc04
for the
Packit 7cfc04
.IR symbolic_mode
Packit 7cfc04
operand. The general conventions for this style of grammar are
Packit 7cfc04
described in
Packit 7cfc04
.IR "Section 1.3" ", " "Grammar Conventions".
Packit 7cfc04
A valid
Packit 7cfc04
.IR symbolic_mode
Packit 7cfc04
can be represented as the non-terminal symbol
Packit 7cfc04
.IR symbolic_mode
Packit 7cfc04
in the grammar. This formal syntax shall take precedence over the
Packit 7cfc04
preceding text syntax description.
Packit 7cfc04
.P
Packit 7cfc04
The lexical processing is based entirely on single characters.
Packit 7cfc04
Implementations need not allow
Packit 7cfc04
<blank>
Packit 7cfc04
characters within the single argument being processed.
Packit 7cfc04
.sp
Packit 7cfc04
.RS 4
Packit 7cfc04
.nf
Packit 7cfc04
\fB
Packit 7cfc04
%start    symbolic_mode
Packit 7cfc04
%%
Packit 7cfc04
.P
Packit 7cfc04
symbolic_mode    : clause
Packit 7cfc04
                 | symbolic_mode ',' clause
Packit 7cfc04
                 ;
Packit 7cfc04
.P
Packit 7cfc04
clause           : actionlist
Packit 7cfc04
                 | wholist actionlist
Packit 7cfc04
                 ;
Packit 7cfc04
.P
Packit 7cfc04
wholist          : who
Packit 7cfc04
                 | wholist who
Packit 7cfc04
                 ;
Packit 7cfc04
.P
Packit 7cfc04
who              : 'u' | 'g' | 'o' | 'a'
Packit 7cfc04
                 ;
Packit 7cfc04
.P
Packit 7cfc04
actionlist       : action
Packit 7cfc04
                 | actionlist action
Packit 7cfc04
                 ;
Packit 7cfc04
.P
Packit 7cfc04
action           : op
Packit 7cfc04
                 | op permlist
Packit 7cfc04
                 | op permcopy
Packit 7cfc04
                 ;
Packit 7cfc04
.P
Packit 7cfc04
permcopy         : 'u' | 'g' | 'o'
Packit 7cfc04
                 ;
Packit 7cfc04
.P
Packit 7cfc04
op               : '+' | '\(mi' | '='
Packit 7cfc04
                 ;
Packit 7cfc04
.P
Packit 7cfc04
permlist         : perm
Packit 7cfc04
                 | perm permlist
Packit 7cfc04
                 ;
Packit 7cfc04
.P
Packit 7cfc04
perm             : 'r' | 'w' | 'x' | 'X' | 's' | 't'  
Packit 7cfc04
                 ;
Packit 7cfc04
.fi \fR
Packit 7cfc04
.P
Packit 7cfc04
.RE
Packit 7cfc04
.SH "EXIT STATUS"
Packit 7cfc04
The following exit values shall be returned:
Packit 7cfc04
.IP "\00" 6
Packit 7cfc04
The utility executed successfully and all requested changes were made.
Packit 7cfc04
.IP >0 6
Packit 7cfc04
An error occurred.
Packit 7cfc04
.SH "CONSEQUENCES OF ERRORS"
Packit 7cfc04
Default.
Packit 7cfc04
.LP
Packit 7cfc04
.IR "The following sections are informative."
Packit 7cfc04
.SH "APPLICATION USAGE"
Packit 7cfc04
Some implementations of the
Packit 7cfc04
.IR chmod
Packit 7cfc04
utility change the mode of a directory before the files in the
Packit 7cfc04
directory when performing a recursive (\c
Packit 7cfc04
.BR \(miR
Packit 7cfc04
option) change; others change the directory mode after the files in the
Packit 7cfc04
directory. If an application tries to remove read or search permission
Packit 7cfc04
for a file hierarchy, the removal attempt fails if the directory is
Packit 7cfc04
changed first; on the other hand, trying to re-enable permissions to a
Packit 7cfc04
restricted hierarchy fails if directories are changed last. Users
Packit 7cfc04
should not try to make a hierarchy inaccessible to themselves.
Packit 7cfc04
.P
Packit 7cfc04
Some implementations of
Packit 7cfc04
.IR chmod
Packit 7cfc04
never used the
Packit 7cfc04
.IR umask
Packit 7cfc04
of the process when changing modes; systems conformant with this volume of POSIX.1\(hy2008
Packit 7cfc04
do so when
Packit 7cfc04
.BR who
Packit 7cfc04
is not specified. Note the difference between:
Packit 7cfc04
.sp
Packit 7cfc04
.RS 4
Packit 7cfc04
.nf
Packit 7cfc04
\fB
Packit 7cfc04
chmod a\(miw file
Packit 7cfc04
.fi \fR
Packit 7cfc04
.P
Packit 7cfc04
.RE
Packit 7cfc04
.P
Packit 7cfc04
which removes all write permissions, and:
Packit 7cfc04
.sp
Packit 7cfc04
.RS 4
Packit 7cfc04
.nf
Packit 7cfc04
\fB
Packit 7cfc04
chmod \(mi\|\(mi \(miw file
Packit 7cfc04
.fi \fR
Packit 7cfc04
.P
Packit 7cfc04
.RE
Packit 7cfc04
.P
Packit 7cfc04
which removes write permissions that would be allowed if
Packit 7cfc04
.BR file
Packit 7cfc04
was created with the same
Packit 7cfc04
.IR umask .
Packit 7cfc04
.P
Packit 7cfc04
Conforming applications should never assume that they know how the
Packit 7cfc04
set-user-ID and set-group-ID bits on directories are interpreted.
Packit 7cfc04
.SH EXAMPLES
Packit 7cfc04
.ad l
Packit 7cfc04
.TS
Packit 7cfc04
center tab(@) box;
Packit 7cfc04
cB | cB
Packit 7cfc04
l | lw(3i).
Packit 7cfc04
Mode@Results
Packit 7cfc04
_
Packit 7cfc04
\fIa\fP+=@T{
Packit 7cfc04
Equivalent to
Packit 7cfc04
.IR a +,\c
Packit 7cfc04
.IR a =;
Packit 7cfc04
clears all file mode bits.
Packit 7cfc04
T}
Packit 7cfc04
\fIgo\fP+\(miw@T{
Packit 7cfc04
Equivalent to
Packit 7cfc04
.IR go +,\c
Packit 7cfc04
.IR go \(mi\c
Packit 7cfc04
.IR w ;
Packit 7cfc04
clears group and other write bits.
Packit 7cfc04
T}
Packit 7cfc04
\fIg\fR=\fIo\fR\(mi\fIw\fR@T{
Packit 7cfc04
Equivalent to
Packit 7cfc04
.IR g =\c
Packit 7cfc04
.IR o ,\c
Packit 7cfc04
.IR g \(mi\c
Packit 7cfc04
.IR w ;
Packit 7cfc04
sets group bit to match other bits and then clears group write bit.
Packit 7cfc04
T}
Packit 7cfc04
\fIg\fR\(mi\fIr\fR+\fIw\fR@T{
Packit 7cfc04
Equivalent to
Packit 7cfc04
.IR g \(mi\c
Packit 7cfc04
.IR r ,\c
Packit 7cfc04
.IR g +\c
Packit 7cfc04
.IR w ;
Packit 7cfc04
clears group read bit and sets group write bit.
Packit 7cfc04
T}
Packit 7cfc04
\fIuo\fR=\fIg\fR@T{
Packit 7cfc04
Sets owner bits to match group bits and sets other bits to
Packit 7cfc04
match group bits.
Packit 7cfc04
T}
Packit 7cfc04
.TE
Packit 7cfc04
.ad b
Packit 7cfc04
.SH RATIONALE
Packit 7cfc04
The functionality of
Packit 7cfc04
.IR chmod
Packit 7cfc04
is described substantially through references to concepts defined in
Packit 7cfc04
the System Interfaces volume of POSIX.1\(hy2008. In this way, there is less duplication of effort required
Packit 7cfc04
for describing the interactions of permissions. However, the behavior
Packit 7cfc04
of this utility is not described in terms of the
Packit 7cfc04
\fIchmod\fR()
Packit 7cfc04
function from the System Interfaces volume of POSIX.1\(hy2008 because that specification requires certain
Packit 7cfc04
side-effects upon alternate file access control mechanisms that might
Packit 7cfc04
not be appropriate, depending on the implementation.
Packit 7cfc04
.P
Packit 7cfc04
Implementations that support mandatory file and record locking as
Packit 7cfc04
specified
Packit 7cfc04
by the 1984 /usr/group standard historically used the combination of set-group-ID bit set
Packit 7cfc04
and group execute bit clear to indicate mandatory locking. This
Packit 7cfc04
condition is usually set or cleared with the symbolic mode
Packit 7cfc04
.BR perm
Packit 7cfc04
symbol
Packit 7cfc04
.BR l
Packit 7cfc04
instead of the
Packit 7cfc04
.BR perm
Packit 7cfc04
symbols
Packit 7cfc04
.BR s
Packit 7cfc04
and
Packit 7cfc04
.BR x
Packit 7cfc04
so that the mandatory locking mode is not changed without explicit
Packit 7cfc04
indication that that was what the user intended. Therefore, the details
Packit 7cfc04
on how the implementation treats these conditions must be defined in
Packit 7cfc04
the documentation. This volume of POSIX.1\(hy2008 does not require mandatory locking (nor does
Packit 7cfc04
the System Interfaces volume of POSIX.1\(hy2008), but does allow it as an extension. However, this volume of POSIX.1\(hy2008 does
Packit 7cfc04
require that the
Packit 7cfc04
.IR ls
Packit 7cfc04
and
Packit 7cfc04
.IR chmod
Packit 7cfc04
utilities work consistently in this area. If
Packit 7cfc04
.IR ls
Packit 7cfc04
.BR \(mil
Packit 7cfc04
.IR file
Packit 7cfc04
indicates that the set-group-ID bit is set,
Packit 7cfc04
.IR chmod
Packit 7cfc04
.BR g\(mis
Packit 7cfc04
.IR file
Packit 7cfc04
must clear it (assuming appropriate privileges exist to change modes).
Packit 7cfc04
.P
Packit 7cfc04
The System V and BSD versions use different exit status codes. Some
Packit 7cfc04
implementations used the exit status as a count of the number of errors
Packit 7cfc04
that occurred; this practice is unworkable since it can overflow the
Packit 7cfc04
range of valid exit status values. This problem is avoided here by
Packit 7cfc04
specifying only 0 and >0 as exit values.
Packit 7cfc04
.P
Packit 7cfc04
The System Interfaces volume of POSIX.1\(hy2008 indicates that implementation-defined restrictions may cause
Packit 7cfc04
the S_ISUID and S_ISGID bits to be ignored. This volume of POSIX.1\(hy2008 allows the
Packit 7cfc04
.IR chmod
Packit 7cfc04
utility to choose to modify these bits before calling
Packit 7cfc04
\fIchmod\fR()
Packit 7cfc04
(or some function providing equivalent capabilities) for non-regular
Packit 7cfc04
files. Among other things, this allows implementations that use the
Packit 7cfc04
set-user-ID and set-group-ID bits on directories to enable extended
Packit 7cfc04
features to
Packit 7cfc04
handle these extensions in an intelligent manner.
Packit 7cfc04
.P
Packit 7cfc04
The
Packit 7cfc04
.BR X
Packit 7cfc04
.BR perm
Packit 7cfc04
symbol was adopted from BSD-based systems because it provides commonly
Packit 7cfc04
desired functionality when doing recursive (\c
Packit 7cfc04
.BR \(miR
Packit 7cfc04
option) modifications. Similar functionality is not provided by the
Packit 7cfc04
.IR find
Packit 7cfc04
utility. Historical BSD versions of
Packit 7cfc04
.IR chmod ,
Packit 7cfc04
however, only supported
Packit 7cfc04
.BR X
Packit 7cfc04
with
Packit 7cfc04
.IR op +;
Packit 7cfc04
it has been extended in this volume of POSIX.1\(hy2008 because it is also useful with
Packit 7cfc04
.IR op =.
Packit 7cfc04
(It has also been added for
Packit 7cfc04
.IR op \(mi
Packit 7cfc04
even though it duplicates
Packit 7cfc04
.BR x ,
Packit 7cfc04
in this case, because it is intuitive and easier to explain.)
Packit 7cfc04
.P
Packit 7cfc04
The grammar was extended with the
Packit 7cfc04
.IR permcopy
Packit 7cfc04
non-terminal to allow historical-practice forms of symbolic modes like
Packit 7cfc04
.BR o =\c
Packit 7cfc04
.BR u
Packit 7cfc04
.BR \(mig
Packit 7cfc04
(that is, set the ``other'' permissions to the permissions of ``owner''
Packit 7cfc04
minus the permissions of ``group'').
Packit 7cfc04
.SH "FUTURE DIRECTIONS"
Packit 7cfc04
None.
Packit 7cfc04
.SH "SEE ALSO"
Packit 7cfc04
.IR "\fIls\fR\^",
Packit 7cfc04
.IR "\fIumask\fR\^"
Packit 7cfc04
.P
Packit 7cfc04
The Base Definitions volume of POSIX.1\(hy2008,
Packit 7cfc04
.IR "Section 4.4" ", " "File Access Permissions",
Packit 7cfc04
.IR "Chapter 8" ", " "Environment Variables",
Packit 7cfc04
.IR "Section 12.2" ", " "Utility Syntax Guidelines"
Packit 7cfc04
.P
Packit 7cfc04
The System Interfaces volume of POSIX.1\(hy2008,
Packit 7cfc04
.IR "\fIchmod\fR\^(\|)"
Packit 7cfc04
.SH COPYRIGHT
Packit 7cfc04
Portions of this text are reprinted and reproduced in electronic form
Packit 7cfc04
from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
Packit 7cfc04
-- Portable Operating System Interface (POSIX), The Open Group Base
Packit 7cfc04
Specifications Issue 7, Copyright (C) 2013 by the Institute of
Packit 7cfc04
Electrical and Electronics Engineers, Inc and The Open Group.
Packit 7cfc04
(This is POSIX.1-2008 with the 2013 Technical Corrigendum 1 applied.) In the
Packit 7cfc04
event of any discrepancy between this version and the original IEEE and
Packit 7cfc04
The Open Group Standard, the original IEEE and The Open Group Standard
Packit 7cfc04
is the referee document. The original Standard can be obtained online at
Packit 7cfc04
http://www.unix.org/online.html .
Packit 7cfc04
Packit 7cfc04
Any typographical or formatting errors that appear
Packit 7cfc04
in this page are most likely
Packit 7cfc04
to have been introduced during the conversion of the source files to
Packit 7cfc04
man page format. To report such errors, see
Packit 7cfc04
https://www.kernel.org/doc/man-pages/reporting_bugs.html .