CHOWN(1POSIX) | POSIX Programmer's Manual | CHOWN(1POSIX) |
This manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (consult the corresponding Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux.
chown — change the file ownership
chown [-h] owner[:group] file...
chown -R [-H|-L|-P] owner[:group] file...
The chown utility shall set the user ID of the file named by each file operand to the user ID specified by the owner operand.
For each file operand, or, if the -R option is used, each file encountered while walking the directory trees specified by the file operands, the chown utility shall perform actions equivalent to the chown() function defined in the System Interfaces volume of POSIX.1‐2017, called with the following arguments:
Unless chown is invoked by a process with appropriate privileges, the set-user-ID and set-group-ID bits of a regular file shall be cleared upon successful completion; the set-user-ID and set-group-ID bits of other file types may be cleared.
The chown utility shall conform to the Base Definitions volume of POSIX.1‐2017, Section 12.2, Utility Syntax Guidelines.
The following options shall be supported by the implementation:
Specifying more than one of the mutually-exclusive options -H, -L, and -P shall not be considered an error. The last option specified shall determine the behavior of the utility.
The following operands shall be supported:
Not used.
None.
The following environment variables shall affect the execution of chown:
Default.
Not used.
The standard error shall be used only for diagnostic messages.
None.
None.
The following exit values shall be returned:
Default.
The following sections are informative.
Only the owner of a file or the user with appropriate privileges may change the owner or group of a file.
Some implementations restrict the use of chown to a user with appropriate privileges.
None.
The System V and BSD versions use different exit status codes. Some implementations used the exit status as a count of the number of errors that occurred; this practice is unworkable since it can overflow the range of valid exit status values. These are masked by specifying only 0 and >0 as exit values.
The functionality of chown is described substantially through references to functions in the System Interfaces volume of POSIX.1‐2017. In this way, there is no duplication of effort required for describing the interactions of permissions, multiple groups, and so on.
The 4.3 BSD method of specifying both owner and group was included in this volume of POSIX.1‐2017 because:
The BSD syntax user[.group] was changed to user[:group] in this volume of POSIX.1‐2017 because the <period> is a valid character in login names (as specified by the Base Definitions volume of POSIX.1‐2017, login names consist of characters in the portable filename character set). The <colon> character was chosen as the replacement for the <period> character because it would never be allowed as a character in a user name or group name on historical implementations.
The -R option is considered by some observers as an undesirable departure from the historical UNIX system tools approach; since a tool, find, already exists to recurse over directories, there seemed to be no good reason to require other tools to have to duplicate that functionality. However, the -R option was deemed an important user convenience, is far more efficient than forking a separate process for each element of the directory hierarchy, and is in widespread historical use.
None.
chgrp, chmod
The Base Definitions volume of POSIX.1‐2017, Chapter 8, Environment Variables, Section 12.2, Utility Syntax Guidelines
The System Interfaces volume of POSIX.1‐2017, chown()
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .
Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .
2017 | IEEE/The Open Group |