Un outil pour savoir si une commande est posix - retour accueil
git clone git://bebou.netlib.re/isposix
Log | Files | Refs | README |
chown.html (15924B)
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>chown</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/chmod.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/cksum.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="chown" id="chown"></a> <a name="tag_20_18" id="tag_20_18"></a><!-- chown --> 29 <h4 class="mansect"><a name="tag_20_18_01" id="tag_20_18_01"></a>NAME</h4> 30 <blockquote>chown — change the file ownership</blockquote> 31 <h4 class="mansect"><a name="tag_20_18_02" id="tag_20_18_02"></a>SYNOPSIS</h4> 32 <blockquote class="synopsis"> 33 <p><code><tt>chown</tt> <b>[</b><tt>-h</tt><b>]</b> <i>owner</i><b>[</b><tt>:</tt><i>group</i><b>]</b> <i>file</i><tt>...<br> 34 <br> 35 chown -R</tt> <b>[</b><tt>-H|-L|-P</tt><b>]</b> <i>owner</i><b>[</b><tt>:</tt><i>group</i><b>]</b> <i>file</i><tt>...<br></tt></code></p> 36 </blockquote> 37 <h4 class="mansect"><a name="tag_20_18_03" id="tag_20_18_03"></a>DESCRIPTION</h4> 38 <blockquote> 39 <p>The <i>chown</i> utility shall set the user ID of the file named by each <i>file</i> operand to the user ID specified by the 40 <i>owner</i> operand.</p> 41 <p>For each <i>file</i> operand, or, if the <b>-R</b> option is used, each file encountered while walking the directory trees 42 specified by the <i>file</i> operands, the <i>chown</i> utility shall perform actions equivalent to the <a href= 43 "../functions/chown.html"><i>chown</i>()</a> function defined in the System Interfaces volume of POSIX.1-2024, called with the 44 following arguments:</p> 45 <ol> 46 <li> 47 <p>The <i>file</i> operand shall be used as the <i>path</i> argument.</p> 48 </li> 49 <li> 50 <p>The user ID indicated by the <i>owner</i> portion of the first operand shall be used as the <i>owner</i> argument.</p> 51 </li> 52 <li> 53 <p>If the <i>group</i> portion of the first operand is given, the group ID indicated by it shall be used as the <i>group</i> 54 argument; otherwise, the group ownership shall not be changed.</p> 55 </li> 56 </ol> 57 <p>Unless <i>chown</i> is invoked by a process with appropriate privileges, the set-user-ID and set-group-ID bits of a regular file 58 shall be cleared upon successful completion; the set-user-ID and set-group-ID bits of other file types may be cleared.</p> 59 </blockquote> 60 <h4 class="mansect"><a name="tag_20_18_04" id="tag_20_18_04"></a>OPTIONS</h4> 61 <blockquote> 62 <p>The <i>chown</i> utility shall conform to XBD <a href="../basedefs/V1_chap12.html#tag_12_02"><i>12.2 Utility Syntax 63 Guidelines</i></a> .</p> 64 <p>The following options shall be supported by the implementation:</p> 65 <dl compact> 66 <dd></dd> 67 <dt><b>-h</b></dt> 68 <dd>For each file operand that names a file of type symbolic link, <i>chown</i> shall attempt to set the user ID of the symbolic 69 link. If a group ID was specified, for each file operand that names a file of type symbolic link, <i>chown</i> shall attempt to set 70 the group ID of the symbolic link.</dd> 71 <dt><b>-H</b></dt> 72 <dd>If the <b>-R</b> option is specified and a symbolic link referencing a file of type directory is specified on the command line, 73 <i>chown</i> shall change the user ID (and group ID, if specified) of the directory referenced by the symbolic link and all files 74 in the file hierarchy below it.</dd> 75 <dt><b>-L</b></dt> 76 <dd>If the <b>-R</b> option is specified and a symbolic link referencing a file of type directory is specified on the command line 77 or encountered during the traversal of a file hierarchy, <i>chown</i> shall change the user ID (and group ID, if specified) of the 78 directory referenced by the symbolic link and all files in the file hierarchy below it.</dd> 79 <dt><b>-P</b></dt> 80 <dd>If the <b>-R</b> option is specified and a symbolic link is specified on the command line or encountered during the traversal 81 of a file hierarchy, <i>chown</i> shall change the owner ID (and group ID, if specified) of the symbolic link. The <i>chown</i> 82 utility shall not follow the symbolic link to any other part of the file hierarchy.</dd> 83 <dt><b>-R</b></dt> 84 <dd>Recursively change file user and group IDs. For each <i>file</i> operand that names a directory, <i>chown</i> shall change the 85 user ID (and group ID, if specified) of the directory and all files in the file hierarchy below it. Unless a <b>-H</b>, <b>-L</b>, 86 or <b>-P</b> option is specified, it is unspecified which of these options will be used as the default.</dd> 87 </dl> 88 <p>Specifying more than one of the mutually-exclusive options <b>-H</b>, <b>-L</b>, and <b>-P</b> shall not be considered an error. 89 The last option specified shall determine the behavior of the utility.</p> 90 </blockquote> 91 <h4 class="mansect"><a name="tag_20_18_05" id="tag_20_18_05"></a>OPERANDS</h4> 92 <blockquote> 93 <p>The following operands shall be supported:</p> 94 <dl compact> 95 <dd></dd> 96 <dt><i>owner</i><b>[</b>:<i>group</i><b>]</b></dt> 97 <dd>A user ID and optional group ID to be assigned to <i>file</i>. The <i>owner</i> portion of this operand shall be a user name 98 from the user database or a numeric user ID. Either specifies a user ID which shall be given to each file named by one of the 99 <i>file</i> operands. If a numeric <i>owner</i> operand exists in the user database as a user name, the user ID number associated 100 with that user name shall be used as the user ID. Similarly, if the <i>group</i> portion of this operand is present, it shall be a 101 group name from the group database or a numeric group ID. Either specifies a group ID which shall be given to each file. If a 102 numeric group operand exists in the group database as a group name, the group ID number associated with that group name shall be 103 used as the group ID.</dd> 104 <dt><i>file</i></dt> 105 <dd>A pathname of a file whose user ID is to be modified.</dd> 106 </dl> 107 </blockquote> 108 <h4 class="mansect"><a name="tag_20_18_06" id="tag_20_18_06"></a>STDIN</h4> 109 <blockquote> 110 <p>Not used.</p> 111 </blockquote> 112 <h4 class="mansect"><a name="tag_20_18_07" id="tag_20_18_07"></a>INPUT FILES</h4> 113 <blockquote> 114 <p>None.</p> 115 </blockquote> 116 <h4 class="mansect"><a name="tag_20_18_08" id="tag_20_18_08"></a>ENVIRONMENT VARIABLES</h4> 117 <blockquote> 118 <p>The following environment variables shall affect the execution of <i>chown</i>:</p> 119 <dl compact> 120 <dd></dd> 121 <dt><i>LANG</i></dt> 122 <dd>Provide a default value for the internationalization variables that are unset or null. (See XBD <a href= 123 "../basedefs/V1_chap08.html#tag_08_02"><i>8.2 Internationalization Variables</i></a> for the precedence of internationalization 124 variables used to determine the values of locale categories.)</dd> 125 <dt><i>LC_ALL</i></dt> 126 <dd>If set to a non-empty string value, override the values of all the other internationalization variables.</dd> 127 <dt><i>LC_CTYPE</i></dt> 128 <dd>Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as 129 opposed to multi-byte characters in arguments).</dd> 130 <dt><i>LC_MESSAGES</i></dt> 131 <dd><br> 132 Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error.</dd> 133 <dt><i>NLSPATH</i></dt> 134 <dd><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> 135 Determine the location of messages objects and message catalogs. <img src="../images/opt-end.gif" alt="[Option End]" border= 136 "0"></dd> 137 </dl> 138 </blockquote> 139 <h4 class="mansect"><a name="tag_20_18_09" id="tag_20_18_09"></a>ASYNCHRONOUS EVENTS</h4> 140 <blockquote> 141 <p>Default.</p> 142 </blockquote> 143 <h4 class="mansect"><a name="tag_20_18_10" id="tag_20_18_10"></a>STDOUT</h4> 144 <blockquote> 145 <p>Not used.</p> 146 </blockquote> 147 <h4 class="mansect"><a name="tag_20_18_11" id="tag_20_18_11"></a>STDERR</h4> 148 <blockquote> 149 <p>The standard error shall be used only for diagnostic messages.</p> 150 </blockquote> 151 <h4 class="mansect"><a name="tag_20_18_12" id="tag_20_18_12"></a>OUTPUT FILES</h4> 152 <blockquote> 153 <p>None.</p> 154 </blockquote> 155 <h4 class="mansect"><a name="tag_20_18_13" id="tag_20_18_13"></a>EXTENDED DESCRIPTION</h4> 156 <blockquote> 157 <p>None.</p> 158 </blockquote> 159 <h4 class="mansect"><a name="tag_20_18_14" id="tag_20_18_14"></a>EXIT STATUS</h4> 160 <blockquote> 161 <p>The following exit values shall be returned:</p> 162 <dl compact> 163 <dd></dd> 164 <dt> 0</dt> 165 <dd>The utility executed successfully and all requested changes were made.</dd> 166 <dt>>0</dt> 167 <dd>An error occurred.</dd> 168 </dl> 169 </blockquote> 170 <h4 class="mansect"><a name="tag_20_18_15" id="tag_20_18_15"></a>CONSEQUENCES OF ERRORS</h4> 171 <blockquote> 172 <p>Default.</p> 173 </blockquote> 174 <hr> 175 <div class="box"><em>The following sections are informative.</em></div> 176 <h4 class="mansect"><a name="tag_20_18_16" id="tag_20_18_16"></a>APPLICATION USAGE</h4> 177 <blockquote> 178 <p>Only the owner of a file or the user with appropriate privileges may change the owner or group of a file.</p> 179 <p>Some implementations restrict the use of <i>chown</i> to a user with appropriate privileges.</p> 180 </blockquote> 181 <h4 class="mansect"><a name="tag_20_18_17" id="tag_20_18_17"></a>EXAMPLES</h4> 182 <blockquote> 183 <p>None.</p> 184 </blockquote> 185 <h4 class="mansect"><a name="tag_20_18_18" id="tag_20_18_18"></a>RATIONALE</h4> 186 <blockquote> 187 <p>The System V and BSD versions use different exit status codes. Some implementations used the exit status as a count of the 188 number of errors that occurred; this practice is unworkable since it can overflow the range of valid exit status values. These are 189 masked by specifying only 0 and >0 as exit values.</p> 190 <p>The functionality of <i>chown</i> is described substantially through references to functions in the System Interfaces volume of 191 POSIX.1-2024. In this way, there is no duplication of effort required for describing the interactions of permissions, multiple 192 groups, and so on.</p> 193 <p>The 4.3 BSD method of specifying both owner and group was included in this volume of POSIX.1-2024 because:</p> 194 <ul> 195 <li> 196 <p>There are cases where the desired end condition could not be achieved using the <a href= 197 "../utilities/chgrp.html"><i>chgrp</i></a> and <i>chown</i> (that only changed the user ID) utilities. (If the current owner is not 198 a member of the desired group and the desired owner is not a member of the current group, the <a href= 199 "../functions/chown.html"><i>chown</i>()</a> function could fail unless both owner and group are changed at the same time.)</p> 200 </li> 201 <li> 202 <p>Even if they could be changed independently, in cases where both are being changed, there is a 100% performance penalty caused 203 by being forced to invoke both utilities.</p> 204 </li> 205 </ul> 206 <p>The BSD syntax <i>user</i>[.<i>group</i>] was changed to <i>user</i>[:<i>group</i>] in this volume of POSIX.1-2024 because the 207 <period> is a valid character in login names (as specified by the Base Definitions volume of POSIX.1-2024, login names 208 consist of characters in the portable filename character set). The <colon> character was chosen as the replacement for the 209 <period> character because it would never be allowed as a character in a user name or group name on historical 210 implementations.</p> 211 <p>The <b>-R</b> option is considered by some observers as an undesirable departure from the historical UNIX system tools approach; 212 since a tool, <a href="../utilities/find.html"><i>find</i></a>, already exists to recurse over directories, there seemed to be no 213 good reason to require other tools to have to duplicate that functionality. However, the <b>-R</b> option was deemed an important 214 user convenience, is far more efficient than forking a separate process for each element of the directory hierarchy, and is in 215 widespread historical use.</p> 216 </blockquote> 217 <h4 class="mansect"><a name="tag_20_18_19" id="tag_20_18_19"></a>FUTURE DIRECTIONS</h4> 218 <blockquote> 219 <p>None.</p> 220 </blockquote> 221 <h4 class="mansect"><a name="tag_20_18_20" id="tag_20_18_20"></a>SEE ALSO</h4> 222 <blockquote> 223 <p><a href="../utilities/chgrp.html#"><i>chgrp</i></a> , <a href="../utilities/chmod.html#tag_20_17"><i>chmod</i></a></p> 224 <p>XBD <a href="../basedefs/V1_chap08.html#tag_08"><i>8. Environment Variables</i></a> , <a href= 225 "../basedefs/V1_chap12.html#tag_12_02"><i>12.2 Utility Syntax Guidelines</i></a></p> 226 <p>XSH <a href="../functions/chown.html#tag_17_73"><i>chown</i></a></p> 227 </blockquote> 228 <h4 class="mansect"><a name="tag_20_18_21" id="tag_20_18_21"></a>CHANGE HISTORY</h4> 229 <blockquote> 230 <p>First released in Issue 2.</p> 231 </blockquote> 232 <h4 class="mansect"><a name="tag_20_18_22" id="tag_20_18_22"></a>Issue 6</h4> 233 <blockquote> 234 <p>New options <b>-h</b>, <b>-H</b>, <b>-L</b>, and <b>-P</b> are added to align with the IEEE P1003.2b draft standard. These 235 options affect the processing of symbolic links.</p> 236 <p>The normative text is reworded to avoid use of the term "must" for application requirements.</p> 237 <p>IEEE PASC Interpretation 1003.2 #172 is applied, changing the CONSEQUENCES OF ERRORS section to "Default.".</p> 238 <p>The "otherwise, ..." text in item 3. of the DESCRIPTION is changed to "otherwise, the group ownership shall not be 239 changed".</p> 240 <p>IEEE Std 1003.1-2001/Cor 1-2002, item XCU/TC1/D6/17 is applied, changing the SYNOPSIS to make it clear that 241 <b>-h</b> and <b>-R</b> are optional.</p> 242 </blockquote> 243 <h4 class="mansect"><a name="tag_20_18_23" id="tag_20_18_23"></a>Issue 7</h4> 244 <blockquote> 245 <p>SD5-XCU-ERN-9 is applied, removing the <b>-R</b> from the first line of the SYNOPSIS.</p> 246 <p>SD5-XCU-ERN-97 is applied, updating the SYNOPSIS.</p> 247 <p>The description of the <b>-h</b> and <b>-P</b> options is revised.</p> 248 </blockquote> 249 <h4 class="mansect"><a name="tag_20_18_24" id="tag_20_18_24"></a>Issue 8</h4> 250 <blockquote> 251 <p>Austin Group Defect 1122 is applied, changing the description of <i>NLSPATH .</i></p> 252 </blockquote> 253 <div class="box"><em>End of informative text.</em></div> 254 <hr> 255 <p> </p> 256 <a href="#top"><span class="topOfPage">return to top of page</span></a><br> 257 <hr size="2" noshade> 258 <center><font size="2">UNIX® is a registered Trademark of The Open Group.<br> 259 POSIX™ is a Trademark of The IEEE.<br> 260 Copyright © 2001-2024 The IEEE and The Open Group, All Rights Reserved<br> 261 [ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href= 262 "../functions/contents.html">XSH</a> | <a href="../utilities/contents.html">XCU</a> | <a href="../xrat/contents.html">XRAT</a> 263 ]</font></center> 264 <hr size="2" noshade> 265 <div class="NAVHEADER"> 266 <table summary="Header navigation table" class="nav" width="100%" border="0" cellpadding="0" cellspacing="0"> 267 <tr class="nav"> 268 <td class="nav" width="15%" align="left" valign="bottom"><a href="../utilities/chmod.html" accesskey="P"><<< 269 Previous</a></td> 270 <td class="nav" width="70%" align="center" valign="bottom"><a href="contents.html">Home</a></td> 271 <td class="nav" width="15%" align="right" valign="bottom"><a href="../utilities/cksum.html" accesskey="N">Next 272 >>></a></td> 273 </tr> 274 </table> 275 <hr align="left" width="100%"></div> 276 </body> 277 </html>