📄 chmod.html
字号:
values will be set.</dl><p>When using the symbolic mode form on a regular file,it is implementation-dependent whether or not:<p><ul><p><li>Requests to set the set-user-ID-on-execution or set-group-ID-on-executionbit when all execute bits are currently clear andnone are being set are ignored.<p><li>Requests to clear all execute bits also clear the set-user-ID-on-executionand set-group-ID-on-execution bits.<p><li>Requests to clear the set-user-ID-on-execution or set-group-ID-on-executionbits when all execute bits are currently clear are ignored.However, if the command<i><a href="ls.html">ls</a></i><b>-l</b><i>file</i>writes ansin the position indicating that theset-user-ID-on-execution or set-group-ID-on-execution is set, thecommands<i>chmod</i><b>u-s</b><i>file</i>or<i>chmod</i><b>g-s</b><i>file</i>,respectively, will not be ignored.<p></ul><p>When using the symbolic mode form on other file types, it isimplementation-dependent whether or not requests to set or clearthe set-user-ID-on-execution or set-group-ID-on-execution bitsare honoured.<p>If the<b>who</b>symbolois used in conjunction with the<b>perm</b>symbolswith noother<b>who</b>symbols being specified, the set-user-ID-on-execution andset-group-ID-on-executionbits will not be modified.It will not be anerror to specify the<b>who</b>symboloin conjunction with the<b>perm</b>symbols.<p>For an octal integer<i>mode</i>operand, the file mode bits will be set absolutely.<p>For each bit set in the octal number, the correspondingfile permission bit shown inthe following table will be set;all other file permission bits will be cleared.For regular files, foreach bit set in the octal number corresponding to theset-user-ID-on-execution or the set-group-ID-on-execution bitsshown in the following table will be set;if these bits are notset in the octal number, they will be cleared.For other filetypes, it is implementation-dependent whether or not requests toset or clear the set-user-ID-on-execution orset-group-ID-on-execution bits are honoured.<pre><table bordercolor=#000000 border=1<tr valign=top><th align=center><b>Octal</b><th align=left>Mode bit<th align=center><b>Octal</b><th align=center><b>Mode bit</b><th align=left>Octal<th align=center><b>Mode bit</b><th align=center><b>Octal</b><th align=left>Mode bit<tr valign=top><td align=left>4000<td align=left>S_ISUID<td align=left>0400<td align=left>S_IRUSR<td align=left>0040<td align=left>S_IRGRP<td align=left>0004<td align=left>S_IROTH<tr valign=top><td align=left>2000<td align=left>S_ISGID<td align=left>0200<td align=left>S_IWUSR<td align=left>0020<td align=left>S_IWGRP<td align=left>0002<td align=left>S_IWOTH<tr valign=top><td align=left> <td align=left> <td align=left>0100<td align=left>S_IXUSR<td align=left>0010<td align=left>S_IXGRP<td align=left>0001<td align=left>S_IXOTH</table></pre><p>When bits are set in the octal number otherthan those listed in the table above, the behaviour is unspecified.<h5><a name = "tag_001_014_047_001"> </a>Grammar for chmod</h5>The grammar and lexical conventions in this section describe the syntaxfor the<b>symbolic_mode</b>operand.The general conventions for this style of grammar are described in<xref href=grammar></xref>.A valid<b>symbolic_mode</b>can be representedas the non-terminal symbol<b>symbolic_mode</b>in the grammar.This formal syntax takes precedence overthe preceding text syntax description.<p>The lexical processing will be based entirely on single characters.Implementations need not allowblank characterswithin the single argument being processed.<p><pre><code>%start symbolic_mode%%symbolic_mode : section | symbolic_mode ',' section ;section : actionlist | wholist actionlist ;wholist : who | wholist who ;who : 'u' | 'g' | 'o' | 'a' ;actionlist : action | actionlist action ;action : op | op permlist | op permcopy ;permcopy : 'u' | 'g' | 'o' ;op : '+' | '-' | '=' ;permlist : perm | perm permlist ;perm : 'r' | 'w' | 'x' | 'X' | 's' ;</code></pre></blockquote><h4><a name = "tag_001_014_048"> </a>EXIT STATUS</h4><blockquote>The following exit values are returned:<dl compact><dt>0<dd>The utility executed successfully and all requested changes were made.<dt>>0<dd>An error occurred.</dl><br></blockquote><h4><a name = "tag_001_014_049"> </a>CONSEQUENCES OF ERRORS</h4><blockquote>If, when invoked with the<b>-R</b>option,<i>chmod</i>attempts but fails to changethe mode of a particular file in a specified file hierarchy, itwill continue to process the remaining files in the hierarchy, affecting thefinal exit status.If<i>chmod</i>cannot read or search a directory within ahierarchy, it will continue to process the other parts of the hierarchythat are accessible.</blockquote><h4><a name = "tag_001_014_050"> </a>APPLICATION USAGE</h4><blockquote>The references to octal modes are supportedbecause, although they are obsolescent in the ISO/IEC 9945-2:1993 standard,XSI-conformant systems have committed to maintaining themfor portable applications until further notice.<p>Some implementations of the<i>chmod</i>utility change the mode of adirectory before the files in the directory when performing a recursive(<b>-R</b>option) change; others change the directory mode after the files inthe directory.If an application tries to remove read or search permission for afile hierarchy, the removal attempt will fail if the directory is changedfirst; on the other hand, trying to re-enable permissions to a restrictedhierarchy will fail if directories are changed last.Users should not try to make ahierarchy inaccessible to themselves.<p>Some implementations of<i>chmod</i>never used the process'<i>umask</i>when changing modes; systems conformant with this specification do so when<b>who</b>is not specified.Note the difference between:<pre><code>chmod a-w file</code></pre>which removes all write permissions, and:<pre><code>chmod -- -w file</code></pre><br>which removes write permissions that would be allowed if<b>file</b>was createdwith the same<i>umask.</i><p>Portable applicationsshould never assume that they know how theset-user-ID and set-group-ID bits on directorieswill be interpreted.<br></blockquote><h4><a name = "tag_001_014_051"> </a>EXAMPLES</h4><blockquote><pre><table bordercolor=#000000 border=1 align=center><tr valign=top><th align=center><b>Mode</b><th align=center><b>Results</b><tr valign=top><td align=left><b>a+=</b><td align=left> Equivalent to clears all file mode bits. <tr valign=top><td align=left><b>go+-w</b><td align=left> Equivalent to clears group and other write bits. <tr valign=top><td align=left><b>g=o-w</b><td align=left> Equivalent to sets group bit to match other bits and then clears group write bit. <tr valign=top><td align=left><b>g-r+w</b><td align=left> Equivalent to clears group read bit and sets group write bit. <tr valign=top><td align=left><b>=g</b><td align=left>Sets owner bits to match group bits and sets other bits to match group bits</table></pre></blockquote><h4><a name = "tag_001_014_052"> </a>FUTURE DIRECTIONS</h4><blockquote>None.</blockquote><h4><a name = "tag_001_014_053"> </a>SEE ALSO</h4><blockquote><i><a href="ls.html">ls</a></i>,<i><a href="umask.html">umask</a></i>,the <b>XSH</b> specification description of<i><a href="../xsh/chmod.html">chmod()</a></i>.</blockquote><hr size=2 noshade><center><font size=2>UNIX ® is a registered Trademark of The Open Group.<br>Copyright © 1997 The Open Group<br> [ <a href="../index.html">Main Index</a> | <a href="../xshix.html">XSH</a> | <a href="../xcuix.html">XCU</a> | <a href="../xbdix.html">XBD</a> | <a href="../cursesix.html">XCURSES</a> | <a href="../xnsix.html">XNS</a> ]</font></center><hr size=2 noshade></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -