xref: /netbsd-src/sbin/chown/chown.8 (revision c2f76ff004a2cb67efe5b12d97bd3ef7fe89e18d)
1.\" Copyright (c) 1990, 1991, 1993, 1994, 2003
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in the
11.\"    documentation and/or other materials provided with the distribution.
12.\" 3. Neither the name of the University nor the names of its contributors
13.\"    may be used to endorse or promote products derived from this software
14.\"    without specific prior written permission.
15.\"
16.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26.\" SUCH DAMAGE.
27.\"
28.\"     from: @(#)chown.8	8.3 (Berkeley) 3/31/94
29.\"	$NetBSD: chown.8,v 1.4 2011/01/13 22:28:36 haad Exp $
30.\"
31.Dd December 9, 2005
32.Dt CHOWN 8
33.Os
34.Sh NAME
35.Nm chown
36.Nd change file owner and group
37.Sh SYNOPSIS
38.Nm
39.Oo
40.Fl R
41.Op Fl H | Fl L | Fl P
42.Oc
43.Op Fl fhv
44.Ar owner Ns Op Ar :group
45.Ar file ...
46.Nm
47.Oo
48.Fl R
49.Op Fl H | Fl L | Fl P
50.Oc
51.Op Fl fhv
52.Ar :group
53.Ar file ...
54.Sh DESCRIPTION
55.Nm
56sets the user ID and/or the group ID of the specified files.
57.Pp
58The options are as follows:
59.Bl -tag -width Ds
60.It Fl H
61If the
62.Fl R
63option is specified, symbolic links on the command line are followed.
64(Symbolic links encountered in the tree traversal are not followed.)
65.It Fl L
66If the
67.Fl R
68option is specified, all symbolic links are followed.
69.It Fl P
70If the
71.Fl R
72option is specified, no symbolic links are followed.
73.It Fl R
74Change the user ID and/or the group ID for the file hierarchies rooted
75in the files instead of just the files themselves.
76.It Fl f
77Don't report any failure to change file owner or group, nor modify
78the exit status to reflect such failures.
79.It Fl h
80If
81.Ar file
82is a symbolic link, the owner and/or group of the link is changed.
83.It Fl v
84Cause
85.Nm
86to be verbose, showing files as they are processed.
87.El
88.Pp
89The
90.Fl H ,
91.Fl L
92and
93.Fl P
94options are ignored unless the
95.Fl R
96option is specified.
97In addition, these options override each other and the
98command's actions are determined by the last one specified.
99.Pp
100The
101.Fl L
102option cannot be used together with the
103.Fl h
104option.
105.Pp
106The
107.Ar owner
108and
109.Ar group
110operands are both optional, however, one must be specified.
111If the
112.Ar group
113operand is specified, it must be preceded by a colon (``:'') character.
114.Pp
115The
116.Ar owner
117may be either a user name or a numeric user ID.
118The
119.Ar group
120may be either a group name or a numeric group ID.
121Since it is valid to have a user or group name that is numeric (and
122doesn't have the numeric ID that matches its name) the name lookup
123is always done first.
124Preceding an ID with a ``#'' character will force it to be taken
125as a number.
126.Pp
127The ownership of a file may only be altered by a super-user for
128obvious security reasons.
129.Pp
130Unless invoked by the super-user,
131.Nm
132clears the set-user-id and set-group-id bits on a file to prevent
133accidental or mischievous creation of set-user-id and set-group-id
134programs.
135.Pp
136The
137.Nm
138utility exits 0 on success, and \*[Gt]0 if an error occurs.
139.Sh COMPATIBILITY
140Previous versions of the
141.Nm
142utility used the dot (``.'') character to distinguish the group name.
143This has been changed to be a colon (``:'') character so that user and
144group names may contain the dot character.
145.Sh SEE ALSO
146.Xr chflags 1 ,
147.Xr chgrp 1 ,
148.Xr find 1 ,
149.Xr chown 2 ,
150.Xr lchown 2 ,
151.Xr fts 3 ,
152.Xr symlink 7
153.Sh STANDARDS
154The
155.Nm
156command is expected to be POSIX 1003.2 compliant.
157.Pp
158The
159.Fl v
160option and the use of ``#'' to force a numeric lookup
161are extensions to
162.St -p1003.2 .
163