Un outil pour savoir si une commande est posix - retour accueil
git clone git://bebou.netlib.re/isposix
Log | Files | Refs | README |
chmod.html (28268B)
1 <!-- Copyright 2001-2024 IEEE and The Open Group, All Rights Reserved --> 2 <!DOCTYPE HTML> 3 <html lang="en"> 4 <head> 5 <meta name="generator" content="HTML Tidy for HTML5 for Linux version 5.8.0"> 6 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 7 <link type="text/css" rel="stylesheet" href="style.css"><!-- Generated by The Open Group rhtm tool v1.2.4 --> 8 <!-- Copyright (c) 2001-2024 The Open Group, All Rights Reserved --> 9 <title>chmod</title> 10 </head> 11 <body bgcolor="white"> 12 <div class="NAVHEADER"> 13 <table summary="Header navigation table" class="nav" width="100%" border="0" cellpadding="0" cellspacing="0"> 14 <tr class="nav"> 15 <td class="nav" width="15%" align="left" valign="bottom"><a href="../utilities/chgrp.html" accesskey="P"><<< 16 Previous</a></td> 17 <td class="nav" width="70%" align="center" valign="bottom"><a href="contents.html">Home</a></td> 18 <td class="nav" width="15%" align="right" valign="bottom"><a href="../utilities/chown.html" accesskey="N">Next 19 >>></a></td> 20 </tr> 21 </table> 22 <hr align="left" width="100%"></div> 23 <script language="JavaScript" src="../jscript/codes.js"></script><basefont size="3"> 24 <center><font size="2">The Open Group Base Specifications Issue 8<br> 25 IEEE Std 1003.1-2024<br> 26 Copyright © 2001-2024 The IEEE and The Open Group</font></center> 27 <hr size="2" noshade> 28 <a name="top" id="top"></a> <a name="chmod" id="chmod"></a> <a name="tag_20_17" id="tag_20_17"></a><!-- chmod --> 29 <h4 class="mansect"><a name="tag_20_17_01" id="tag_20_17_01"></a>NAME</h4> 30 <blockquote>chmod — change the file modes</blockquote> 31 <h4 class="mansect"><a name="tag_20_17_02" id="tag_20_17_02"></a>SYNOPSIS</h4> 32 <blockquote class="synopsis"> 33 <p><code><tt>chmod</tt> <b>[</b><tt>-R</tt><b>]</b> <i>mode file</i><tt>...</tt></code></p> 34 </blockquote> 35 <h4 class="mansect"><a name="tag_20_17_03" id="tag_20_17_03"></a>DESCRIPTION</h4> 36 <blockquote> 37 <p>The <i>chmod</i> utility shall change any or all of the file mode bits of the file named by each <i>file</i> operand in the way 38 specified by the <i>mode</i> operand.</p> 39 <p>It is implementation-defined whether and how the <i>chmod</i> utility affects any alternate or additional file access control 40 mechanism (see XBD <a href="../basedefs/V1_chap04.html#tag_04_07"><i>4.7 File Access Permissions</i></a> ) being used for the 41 specified file.</p> 42 <p>Only a process whose effective user ID matches the user ID of the file, or a process with appropriate privileges, shall be 43 permitted to change the file mode bits of a file.</p> 44 <p>Upon successfully changing the file mode bits of a file, the <i>chmod</i> utility shall mark for update the last file status 45 change timestamp of the file.</p> 46 </blockquote> 47 <h4 class="mansect"><a name="tag_20_17_04" id="tag_20_17_04"></a>OPTIONS</h4> 48 <blockquote> 49 <p>The <i>chmod</i> utility shall conform to XBD <a href="../basedefs/V1_chap12.html#tag_12_02"><i>12.2 Utility Syntax 50 Guidelines</i></a> .</p> 51 <p>The following option shall be supported:</p> 52 <dl compact> 53 <dd></dd> 54 <dt><b>-R</b></dt> 55 <dd>Recursively change file mode bits. For each <i>file</i> operand that names a directory, <i>chmod</i> shall change the file mode 56 bits of the directory and all files in the file hierarchy below it.</dd> 57 </dl> 58 </blockquote> 59 <h4 class="mansect"><a name="tag_20_17_05" id="tag_20_17_05"></a>OPERANDS</h4> 60 <blockquote> 61 <p>The following operands shall be supported:</p> 62 <dl compact> 63 <dd></dd> 64 <dt><i>mode</i></dt> 65 <dd>Represents the change to be made to the file mode bits of each file named by one of the <i>file</i> operands; see the EXTENDED 66 DESCRIPTION section.</dd> 67 <dt><i>file</i></dt> 68 <dd>A pathname of a file whose file mode bits shall be modified.</dd> 69 </dl> 70 </blockquote> 71 <h4 class="mansect"><a name="tag_20_17_06" id="tag_20_17_06"></a>STDIN</h4> 72 <blockquote> 73 <p>Not used.</p> 74 </blockquote> 75 <h4 class="mansect"><a name="tag_20_17_07" id="tag_20_17_07"></a>INPUT FILES</h4> 76 <blockquote> 77 <p>None.</p> 78 </blockquote> 79 <h4 class="mansect"><a name="tag_20_17_08" id="tag_20_17_08"></a>ENVIRONMENT VARIABLES</h4> 80 <blockquote> 81 <p>The following environment variables shall affect the execution of <i>chmod</i>:</p> 82 <dl compact> 83 <dd></dd> 84 <dt><i>LANG</i></dt> 85 <dd>Provide a default value for the internationalization variables that are unset or null. (See XBD <a href= 86 "../basedefs/V1_chap08.html#tag_08_02"><i>8.2 Internationalization Variables</i></a> for the precedence of internationalization 87 variables used to determine the values of locale categories.)</dd> 88 <dt><i>LC_ALL</i></dt> 89 <dd>If set to a non-empty string value, override the values of all the other internationalization variables.</dd> 90 <dt><i>LC_CTYPE</i></dt> 91 <dd>Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as 92 opposed to multi-byte characters in arguments).</dd> 93 <dt><i>LC_MESSAGES</i></dt> 94 <dd><br> 95 Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error.</dd> 96 <dt><i>NLSPATH</i></dt> 97 <dd><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> 98 Determine the location of messages objects and message catalogs. <img src="../images/opt-end.gif" alt="[Option End]" border= 99 "0"></dd> 100 </dl> 101 </blockquote> 102 <h4 class="mansect"><a name="tag_20_17_09" id="tag_20_17_09"></a>ASYNCHRONOUS EVENTS</h4> 103 <blockquote> 104 <p>Default.</p> 105 </blockquote> 106 <h4 class="mansect"><a name="tag_20_17_10" id="tag_20_17_10"></a>STDOUT</h4> 107 <blockquote> 108 <p>Not used.</p> 109 </blockquote> 110 <h4 class="mansect"><a name="tag_20_17_11" id="tag_20_17_11"></a>STDERR</h4> 111 <blockquote> 112 <p>The standard error shall be used only for diagnostic messages.</p> 113 </blockquote> 114 <h4 class="mansect"><a name="tag_20_17_12" id="tag_20_17_12"></a>OUTPUT FILES</h4> 115 <blockquote> 116 <p>None.</p> 117 </blockquote> 118 <h4 class="mansect"><a name="tag_20_17_13" id="tag_20_17_13"></a>EXTENDED DESCRIPTION</h4> 119 <blockquote> 120 <p>The <i>mode</i> operand shall be either a <i>symbolic_mode</i> expression or a non-negative octal integer. The 121 <i>symbolic_mode</i> form is described by the grammar later in this section.</p> 122 <p>Each <b>clause</b> shall specify an operation to be performed on the current file mode bits of each <i>file</i>. The operations 123 shall be performed on each <i>file</i> in the order in which the <b>clause</b>s are specified.</p> 124 <p>The <b>who</b> symbols <b>u</b>, <b>g</b>, and <b>o</b> shall specify the <i>user</i>, <i>group</i>, and <i>other</i> parts of 125 the file mode bits, respectively. A <b>who</b> consisting of the symbol <b>a</b> shall be equivalent to <b>ugo</b>.</p> 126 <p>The <b>perm</b> symbols <b>r</b>, <b>w</b>, and <b>x</b> represent the <i>read</i>, <i>write</i>, and 127 <i>execute</i>/<i>search</i> portions of file mode bits, respectively. The <b>perm</b> symbol <b>s</b> shall represent the 128 <i>set-user-ID-on-execution</i> (when <b>who</b> contains or implies <b>u</b>) and <i>set-group-ID-on-execution</i> (when 129 <b>who</b> contains or implies <b>g</b>) bits.</p> 130 <p>The <b>perm</b> symbol <b>X</b> shall represent the execute/search portion of the file mode bits if the file is a directory or 131 if the current (unmodified) file mode bits have at least one of the execute bits (S_IXUSR, S_IXGRP, or S_IXOTH) set. It shall be 132 ignored if the file is not a directory and none of the execute bits are set in the current file mode bits.</p> 133 <p>The <b>permcopy</b> symbols <b>u</b>, <b>g</b>, and <b>o</b> shall represent the current permissions associated with the user, 134 group, and other parts of the file mode bits, respectively. For the remainder of this section, <b>perm</b> refers to the 135 non-terminals <b>perm</b> and <b>permcopy</b> in the grammar.</p> 136 <p>If multiple <b>actionlist</b>s are grouped with a single <b>wholist</b> in the grammar, each <b>actionlist</b> shall be applied 137 in the order specified with that <b>wholist</b>. The <i>op</i> symbols shall represent the operation performed, as follows:</p> 138 <dl compact> 139 <dd></dd> 140 <dt><tt>+</tt></dt> 141 <dd>If <b>perm</b> is not specified, the <tt>'+'</tt> operation shall not change the file mode bits. 142 <p>If <b>who</b> is not specified, the file mode bits represented by <b>perm</b> for the owner, group, and other permissions, 143 except for those with corresponding bits in the file mode creation mask of the invoking process, shall be set.</p> 144 <p>Otherwise, the file mode bits represented by the specified <b>who</b> and <b>perm</b> values shall be set.</p> 145 </dd> 146 <dt><tt>-</tt></dt> 147 <dd>If <b>perm</b> is not specified, the <tt>'-'</tt> operation shall not change the file mode bits. 148 <p>If <b>who</b> is not specified, the file mode bits represented by <b>perm</b> for the owner, group, and other permissions, 149 except for those with corresponding bits in the file mode creation mask of the invoking process, shall be cleared.</p> 150 <p>Otherwise, the file mode bits represented by the specified <b>who</b> and <b>perm</b> values shall be cleared.</p> 151 </dd> 152 <dt><tt>=</tt></dt> 153 <dd>Clear the file mode bits specified by the <b>who</b> value, or, if no <b>who</b> value is specified, all of the file mode bits 154 specified in this volume of POSIX.1-2024. 155 <p>If <b>perm</b> is not specified, the <tt>'='</tt> operation shall make no further modifications to the file mode bits.</p> 156 <p>If <b>who</b> is not specified, the file mode bits represented by <b>perm</b> for the owner, group, and other permissions, 157 except for those with corresponding bits in the file mode creation mask of the invoking process, shall be set.</p> 158 <p>Otherwise, the file mode bits represented by the specified <b>who</b> and <b>perm</b> values shall be set.</p> 159 </dd> 160 </dl> 161 <p>When using the symbolic mode form on a regular file, it is implementation-defined whether or not:</p> 162 <ul> 163 <li> 164 <p>Requests to set the set-user-ID-on-execution or set-group-ID-on-execution bit when all execute bits are currently clear and none 165 are being set are ignored.</p> 166 </li> 167 <li> 168 <p>Requests to clear all execute bits also clear the set-user-ID-on-execution and set-group-ID-on-execution bits.</p> 169 </li> 170 <li> 171 <p>Requests to clear the set-user-ID-on-execution or set-group-ID-on-execution bits when all execute bits are currently clear are 172 ignored. However, if the command <a href="../utilities/ls.html"><i>ls</i></a> <b>-l</b> <i>file</i> writes an <i>s</i> in the 173 position indicating that the set-user-ID-on-execution or set-group-ID-on-execution is set, the commands <i>chmod</i> <b>u-s</b> 174 <i>file</i> or <i>chmod</i> <b>g-s</b> <i>file</i>, respectively, shall not be ignored.</p> 175 </li> 176 </ul> 177 <p>When using the symbolic mode form on other file types, it is implementation-defined whether or not requests to set or clear the 178 set-user-ID-on-execution or set-group-ID-on-execution bits are honored.</p> 179 <p>If the <b>who</b> symbol <b>o</b> is used in conjunction with the <b>perm</b> symbol <b>s</b> with no other <b>who</b> symbols 180 being specified, the set-user-ID-on-execution and set-group-ID-on-execution bits shall not be modified. It shall not be an error to 181 specify the <b>who</b> symbol <b>o</b> in conjunction with the <b>perm</b> symbol <b>s</b>.</p> 182 <p><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> 183 The <b>perm</b> symbol <b>t</b> shall specify the S_ISVTX bit. When used with a file of type directory, it can be used with the 184 <b>who</b> symbol <b>a</b>, or with no <b>who</b> symbol. It shall not be an error to specify a <b>who</b> symbol of <b>u</b>, 185 <b>g</b>, or <b>o</b> in conjunction with the <b>perm</b> symbol <b>t</b>, but the meaning of these combinations is unspecified. 186 The effect when using the <b>perm</b> symbol <b>t</b> with any file type other than directory is unspecified. <img src= 187 "../images/opt-end.gif" alt="[Option End]" border="0"></p> 188 <p>For an octal integer <i>mode</i> operand, the file mode bits shall be set absolutely.</p> 189 <p>For each bit set in the octal number, the corresponding file permission bit shown in the following table shall be set; all other 190 file permission bits shall be cleared. For regular files, for each bit set in the octal number corresponding to the 191 set-user-ID-on-execution or the set-group-ID-on-execution, bits shown in the following table shall be set; if these bits are not 192 set in the octal number, they are cleared. For other file types, it is implementation-defined whether or not requests to set or 193 clear the set-user-ID-on-execution or set-group-ID-on-execution bits are honored.</p> 194 <center> 195 <table border="1" cellpadding="3" align="center"> 196 <tr valign="top"> 197 <th align="center"> 198 <p class="tent"><b>Octal</b></p> 199 </th> 200 <th align="center"> 201 <p class="tent"><b>Mode Bit</b></p> 202 </th> 203 <th align="center"> 204 <p class="tent"><b>Octal</b></p> 205 </th> 206 <th align="center"> 207 <p class="tent"><b>Mode Bit</b></p> 208 </th> 209 <th align="center"> 210 <p class="tent"><b>Octal</b></p> 211 </th> 212 <th align="center"> 213 <p class="tent"><b>Mode Bit</b></p> 214 </th> 215 <th align="center"> 216 <p class="tent"><b>Octal</b></p> 217 </th> 218 <th align="center"> 219 <p class="tent"><b>Mode Bit</b></p> 220 </th> 221 </tr> 222 <tr valign="top"> 223 <td align="left"> 224 <p class="tent"><b>4000</b></p> 225 </td> 226 <td align="left"> 227 <p class="tent">S_ISUID</p> 228 </td> 229 <td align="left"> 230 <p class="tent"><b>0400</b></p> 231 </td> 232 <td align="left"> 233 <p class="tent">S_IRUSR</p> 234 </td> 235 <td align="left"> 236 <p class="tent"><b>0040</b></p> 237 </td> 238 <td align="left"> 239 <p class="tent">S_IRGRP</p> 240 </td> 241 <td align="left"> 242 <p class="tent"><b>0004</b></p> 243 </td> 244 <td align="left"> 245 <p class="tent">S_IROTH</p> 246 </td> 247 </tr> 248 <tr valign="top"> 249 <td align="left"> 250 <p class="tent"><b>2000</b></p> 251 </td> 252 <td align="left"> 253 <p class="tent">S_ISGID</p> 254 </td> 255 <td align="left"> 256 <p class="tent"><b>0200</b></p> 257 </td> 258 <td align="left"> 259 <p class="tent">S_IWUSR</p> 260 </td> 261 <td align="left"> 262 <p class="tent"><b>0020</b></p> 263 </td> 264 <td align="left"> 265 <p class="tent">S_IWGRP</p> 266 </td> 267 <td align="left"> 268 <p class="tent"><b>0002</b></p> 269 </td> 270 <td align="left"> 271 <p class="tent">S_IWOTH</p> 272 </td> 273 </tr> 274 <tr valign="top"> 275 <td align="left"> 276 <p class="tent"><b><img src="../images/opt-start.gif" border="0">1000</b></p> 277 </td> 278 <td align="left"> 279 <p class="tent">S_ISVTX<img src="../images/opt-end.gif" border="0"></p> 280 </td> 281 <td align="left"> 282 <p class="tent"><b>0100</b></p> 283 </td> 284 <td align="left"> 285 <p class="tent">S_IXUSR</p> 286 </td> 287 <td align="left"> 288 <p class="tent"><b>0010</b></p> 289 </td> 290 <td align="left"> 291 <p class="tent">S_IXGRP</p> 292 </td> 293 <td align="left"> 294 <p class="tent"><b>0001</b></p> 295 </td> 296 <td align="left"> 297 <p class="tent">S_IXOTH</p> 298 </td> 299 </tr> 300 </table> 301 </center> 302 <p class="tent">When bits are set in the octal number other than those listed in the table above, the behavior is unspecified.</p> 303 <h5><a name="tag_20_17_13_01" id="tag_20_17_13_01"></a>Grammar for chmod</h5> 304 <p class="tent">The grammar and lexical conventions in this section describe the syntax for the <i>symbolic_mode</i> operand. The 305 general conventions for this style of grammar are described in <a href="../utilities/V3_chap01.html#tag_18_03"><i>1.3 Grammar 306 Conventions</i></a> . A valid <i>symbolic_mode</i> can be represented as the non-terminal symbol <i>symbolic_mode</i> in the 307 grammar. This formal syntax shall take precedence over the preceding text syntax description.</p> 308 <p class="tent">The lexical processing is based entirely on single characters. Implementations need not allow <blank> 309 characters within the single argument being processed.</p> 310 <pre> 311 <tt>%start symbolic_mode 312 %% 313 <br class="tent"> 314 symbolic_mode : clause 315 | symbolic_mode ',' clause 316 ; 317 <br class="tent"> 318 clause : actionlist 319 | wholist actionlist 320 ; 321 <br class="tent"> 322 wholist : who 323 | wholist who 324 ; 325 <br class="tent"> 326 who : 'u' | 'g' | 'o' | 'a' 327 ; 328 <br class="tent"> 329 actionlist : action 330 | actionlist action 331 ; 332 <br class="tent"> 333 action : op 334 | op permlist 335 | op permcopy 336 ; 337 <br class="tent"> 338 permcopy : 'u' | 'g' | 'o' 339 ; 340 <br class="tent"> 341 op : '+' | '-' | '=' 342 ; 343 <br class="tent"> 344 permlist : perm 345 | perm permlist 346 ; 347 <br class="tent"> 348 <sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> 349 perm : 'r' | 'w' | 'x' | 'X' | 's' |<img src="../images/opt-start.gif" border="0"> 't' <img src= 350 "../images/opt-end.gif" border="0"> 351 ; 352 </tt></pre></blockquote> 353 <h4 class="mansect"><a name="tag_20_17_14" id="tag_20_17_14"></a>EXIT STATUS</h4> 354 <blockquote> 355 <p>The following exit values shall be returned:</p> 356 <dl compact> 357 <dd></dd> 358 <dt> 0</dt> 359 <dd>The utility executed successfully and all requested changes were made.</dd> 360 <dt>>0</dt> 361 <dd>An error occurred.</dd> 362 </dl> 363 </blockquote> 364 <h4 class="mansect"><a name="tag_20_17_15" id="tag_20_17_15"></a>CONSEQUENCES OF ERRORS</h4> 365 <blockquote> 366 <p>Default.</p> 367 </blockquote> 368 <hr> 369 <div class="box"><em>The following sections are informative.</em></div> 370 <h4 class="mansect"><a name="tag_20_17_16" id="tag_20_17_16"></a>APPLICATION USAGE</h4> 371 <blockquote> 372 <p>Some implementations of the <i>chmod</i> utility change the mode of a directory before the files in the directory when 373 performing a recursive (<b>-R</b> option) change; others change the directory mode after the files in the directory. If an 374 application tries to remove read or search permission for a file hierarchy, the removal attempt fails if the directory is changed 375 first; on the other hand, trying to re-enable permissions to a restricted hierarchy fails if directories are changed last. Users 376 should not try to make a hierarchy inaccessible to themselves.</p> 377 <p class="tent">Some implementations of <i>chmod</i> never used the <a href="../utilities/umask.html"><i>umask</i></a> of the 378 process when changing modes; systems conformant with this volume of POSIX.1-2024 do so when <b>who</b> is not specified. Note the 379 difference between:</p> 380 <pre> 381 <tt>chmod a-w file 382 </tt></pre> 383 <p class="tent">which removes all write permissions, and:</p> 384 <pre> 385 <tt>chmod -- -w file 386 </tt></pre> 387 <p class="tent">which removes write permissions that would be allowed if <b>file</b> was created with the same <a href= 388 "../utilities/umask.html"><i>umask</i></a>.</p> 389 <p class="tent">Conforming applications should never assume that they know how the set-user-ID and set-group-ID bits on directories 390 are interpreted.</p> 391 </blockquote> 392 <h4 class="mansect"><a name="tag_20_17_17" id="tag_20_17_17"></a>EXAMPLES</h4> 393 <blockquote> 394 <center> 395 <table border="1" cellpadding="3" align="center"> 396 <tr valign="top"> 397 <th align="center"> 398 <p class="tent"><b>Mode</b></p> 399 </th> 400 <th align="center"> 401 <p class="tent"><b>Results</b></p> 402 </th> 403 </tr> 404 <tr valign="top"> 405 <td align="left"> 406 <p class="tent"><i>a</i>+=</p> 407 </td> 408 <td align="left"> 409 <p class="tent">Equivalent to <i>a</i>+,<i>a</i>=; clears all file mode bits.</p> 410 </td> 411 </tr> 412 <tr valign="top"> 413 <td align="left"> 414 <p class="tent"><i>go</i>+-w</p> 415 </td> 416 <td align="left"> 417 <p class="tent">Equivalent to <i>go</i>+,<i>go</i>-<i>w</i>; clears group and other write bits.</p> 418 </td> 419 </tr> 420 <tr valign="top"> 421 <td align="left"> 422 <p class="tent"><i>g</i>=<i>o</i>-<i>w</i></p> 423 </td> 424 <td align="left"> 425 <p class="tent">Equivalent to <i>g</i>=<i>o</i>,<i>g</i>-<i>w</i>; sets group bit to match other bits and then clears group write 426 bit.</p> 427 </td> 428 </tr> 429 <tr valign="top"> 430 <td align="left"> 431 <p class="tent"><i>g</i>-<i>r</i>+<i>w</i></p> 432 </td> 433 <td align="left"> 434 <p class="tent">Equivalent to <i>g</i>-<i>r</i>,<i>g</i>+<i>w</i>; clears group read bit and sets group write bit.</p> 435 </td> 436 </tr> 437 <tr valign="top"> 438 <td align="left"> 439 <p class="tent"><i>uo</i>=<i>g</i></p> 440 </td> 441 <td align="left"> 442 <p class="tent">Sets owner bits to match group bits and sets other bits to match group bits.</p> 443 </td> 444 </tr> 445 </table> 446 </center> 447 </blockquote> 448 <h4 class="mansect"><a name="tag_20_17_18" id="tag_20_17_18"></a>RATIONALE</h4> 449 <blockquote> 450 <p>The functionality of <i>chmod</i> is described substantially through references to concepts defined in the System Interfaces 451 volume of POSIX.1-2024. In this way, there is less duplication of effort required for describing the interactions of permissions. 452 However, the behavior of this utility is not described in terms of the <a href="../functions/chmod.html"><i>chmod</i>()</a> 453 function from the System Interfaces volume of POSIX.1-2024 because that specification requires certain side-effects upon alternate 454 file access control mechanisms that might not be appropriate, depending on the implementation.</p> 455 <p class="tent">Implementations that support mandatory file and record locking as specified by the 1984 /usr/group standard 456 historically used the combination of set-group-ID bit set and group execute bit clear to indicate mandatory locking. This condition 457 is usually set or cleared with the symbolic mode <b>perm</b> symbol <b>l</b> instead of the <b>perm</b> symbols <b>s</b> and 458 <b>x</b> so that the mandatory locking mode is not changed without explicit indication that that was what the user intended. 459 Therefore, the details on how the implementation treats these conditions must be defined in the documentation. This volume of 460 POSIX.1-2024 does not require mandatory locking (nor does the System Interfaces volume of POSIX.1-2024), but does allow it as an 461 extension. However, this volume of POSIX.1-2024 does require that the <a href="../utilities/ls.html"><i>ls</i></a> and <i>chmod</i> 462 utilities work consistently in this area. If <a href="../utilities/ls.html"><i>ls</i></a> <b>-l</b> <i>file</i> indicates that the 463 set-group-ID bit is set, <i>chmod</i> <b>g-s</b> <i>file</i> must clear it (assuming appropriate privileges exist to change 464 modes).</p> 465 <p class="tent">The System V and BSD versions use different exit status codes. Some implementations used the exit status as a count 466 of the number of errors that occurred; this practice is unworkable since it can overflow the range of valid exit status values. 467 This problem is avoided here by specifying only 0 and >0 as exit values.</p> 468 <p class="tent">The System Interfaces volume of POSIX.1-2024 indicates that implementation-defined restrictions may cause the 469 S_ISUID and S_ISGID bits to be ignored. This volume of POSIX.1-2024 allows the <i>chmod</i> utility to choose to modify these bits 470 before calling <a href="../functions/chmod.html"><i>chmod</i>()</a> (or some function providing equivalent capabilities) for 471 non-regular files. Among other things, this allows implementations that use the set-user-ID and set-group-ID bits on directories to 472 enable extended features to handle these extensions in an intelligent manner.</p> 473 <p class="tent">The <b>X</b> <b>perm</b> symbol was adopted from BSD-based systems because it provides commonly desired 474 functionality when doing recursive (<b>-R</b> option) modifications. Similar functionality is not provided by the <a href= 475 "../utilities/find.html"><i>find</i></a> utility. Historical BSD versions of <i>chmod</i>, however, only supported <b>X</b> with 476 <i>op</i>+; it has been extended in this volume of POSIX.1-2024 because it is also useful with <i>op</i>=. (It has also been added 477 for <i>op</i>- even though it duplicates <b>x</b>, in this case, because it is intuitive and easier to explain.)</p> 478 <p class="tent">The grammar was extended with the <i>permcopy</i> non-terminal to allow historical-practice forms of symbolic modes 479 like <b>o</b>=<b>u</b> <b>-g</b> (that is, set the "other" permissions to the permissions of "owner" minus the permissions of 480 "group").</p> 481 </blockquote> 482 <h4 class="mansect"><a name="tag_20_17_19" id="tag_20_17_19"></a>FUTURE DIRECTIONS</h4> 483 <blockquote> 484 <p>None.</p> 485 </blockquote> 486 <h4 class="mansect"><a name="tag_20_17_20" id="tag_20_17_20"></a>SEE ALSO</h4> 487 <blockquote> 488 <p><a href="../utilities/ls.html#"><i>ls</i></a> , <a href="../utilities/umask.html#tag_20_132"><i>umask</i></a></p> 489 <p class="tent">XBD <a href="../basedefs/V1_chap04.html#tag_04_07"><i>4.7 File Access Permissions</i></a> , <a href= 490 "../basedefs/V1_chap08.html#tag_08"><i>8. Environment Variables</i></a> , <a href="../basedefs/V1_chap12.html#tag_12_02"><i>12.2 491 Utility Syntax Guidelines</i></a></p> 492 <p class="tent">XSH <a href="../functions/chmod.html#tag_17_72"><i>chmod</i></a></p> 493 </blockquote> 494 <h4 class="mansect"><a name="tag_20_17_21" id="tag_20_17_21"></a>CHANGE HISTORY</h4> 495 <blockquote> 496 <p>First released in Issue 2.</p> 497 </blockquote> 498 <h4 class="mansect"><a name="tag_20_17_22" id="tag_20_17_22"></a>Issue 6</h4> 499 <blockquote> 500 <p>The following new requirements on POSIX implementations derive from alignment with the Single UNIX Specification:</p> 501 <ul> 502 <li class="tent">Octal modes have been kept and made mandatory despite being marked obsolescent in the ISO POSIX-2:1993 503 standard.</li> 504 </ul> 505 <p class="tent">IEEE PASC Interpretation 1003.2 #172 is applied, changing the CONSEQUENCES OF ERRORS section to "Default.".</p> 506 <p class="tent">The Open Group Base Resolution bwg2001-010 is applied, adding the description of the S_ISVTX bit and the 507 <b>t perm</b> symbol as part of the XSI option.</p> 508 <p class="tent">IEEE Std 1003.1-2001/Cor 1-2002, item XCU/TC1/D6/16 is applied, changing the XSI shaded text in the 509 EXTENDED DESCRIPTION from:</p> 510 <blockquote>"The <b>perm</b> symbol <b>t</b> shall specify the S_ISVTX bit and shall apply to directories only. The effect when 511 using it with any other file type is unspecified. It can be used with the <b>who</b> symbols <b>o</b>, <b>a</b>, or with no 512 <b>who</b> symbol. It shall not be an error to specify a <b>who</b> symbol of <b>u</b> or <b>g</b> in conjunction with the 513 <b>perm</b> symbol <b>t</b>; it shall be ignored for <b>u</b> and <b>g</b>."</blockquote> 514 <p class="tent">to:</p> 515 <blockquote>"The <b>perm</b> symbol <b>t</b> shall specify the S_ISVTX bit. When used with a file of type directory, it can be 516 used with the <b>who</b> symbol <b>a</b>, or with no <b>who</b> symbol. It shall not be an error to specify a <b>who</b> symbol of 517 <b>u</b>, <b>g</b>, or <b>o</b> in conjunction with the <b>perm</b> symbol <b>t</b>, but the meaning of these combinations is 518 unspecified. The effect when using the <b>perm</b> symbol <b>t</b> with any file type other than directory is 519 unspecified."</blockquote> 520 <p class="tent">This change is to permit historical behavior.</p> 521 </blockquote> 522 <h4 class="mansect"><a name="tag_20_17_23" id="tag_20_17_23"></a>Issue 7</h4> 523 <blockquote> 524 <p>SD5-XCU-ERN-97 is applied, updating the SYNOPSIS.</p> 525 <p class="tent">Austin Group Interpretation 1003.1-2001 #130 is applied, adding text to the DESCRIPTION about about marking for 526 update the last file status change timestamp of the file.</p> 527 </blockquote> 528 <h4 class="mansect"><a name="tag_20_17_24" id="tag_20_17_24"></a>Issue 8</h4> 529 <blockquote> 530 <p>Austin Group Defect 1122 is applied, changing the description of <i>NLSPATH .</i></p> 531 </blockquote> 532 <div class="box"><em>End of informative text.</em></div> 533 <hr> 534 <p> </p> 535 <a href="#top"><span class="topOfPage">return to top of page</span></a><br> 536 <hr size="2" noshade> 537 <center><font size="2">UNIX® is a registered Trademark of The Open Group.<br> 538 POSIX™ is a Trademark of The IEEE.<br> 539 Copyright © 2001-2024 The IEEE and The Open Group, All Rights Reserved<br> 540 [ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href= 541 "../functions/contents.html">XSH</a> | <a href="../utilities/contents.html">XCU</a> | <a href="../xrat/contents.html">XRAT</a> 542 ]</font></center> 543 <hr size="2" noshade> 544 <div class="NAVHEADER"> 545 <table summary="Header navigation table" class="nav" width="100%" border="0" cellpadding="0" cellspacing="0"> 546 <tr class="nav"> 547 <td class="nav" width="15%" align="left" valign="bottom"><a href="../utilities/chgrp.html" accesskey="P"><<< 548 Previous</a></td> 549 <td class="nav" width="70%" align="center" valign="bottom"><a href="contents.html">Home</a></td> 550 <td class="nav" width="15%" align="right" valign="bottom"><a href="../utilities/chown.html" accesskey="N">Next 551 >>></a></td> 552 </tr> 553 </table> 554 <hr align="left" width="100%"></div> 555 </body> 556 </html>