xref: /netbsd-src/sbin/chown/chown.8 (revision 6a493d6bc668897c91594964a732d38505b70cbb)
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.7 2013/12/17 09:54:08 apb Exp $
30.\"
31.Dd October 22, 2012
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
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
54.Nm
55.Oo
56.Fl R
57.Op Fl H | Fl L | Fl P
58.Oc
59.Op Fl fhv
60.Fl Fl reference=rfile
61.Ar
62.Sh DESCRIPTION
63.Nm
64sets the user ID and/or the group ID of the specified files.
65.Pp
66The options are as follows:
67.Bl -tag -width Ds
68.It Fl H
69If the
70.Fl R
71option is specified, symbolic links on the command line are followed.
72(Symbolic links encountered in the tree traversal are not followed.)
73.It Fl L
74If the
75.Fl R
76option is specified, all symbolic links are followed.
77.It Fl P
78If the
79.Fl R
80option is specified, no symbolic links are followed.
81.It Fl R
82Change the user ID and/or the group ID for the file hierarchies rooted
83in the files instead of just the files themselves.
84.It Fl f
85Don't report any failure to change file owner or group, nor modify
86the exit status to reflect such failures.
87.It Fl h
88If
89.Ar file
90is a symbolic link, the owner and/or group of the link is changed.
91.It Fl v
92Cause
93.Nm
94to be verbose, showing files as they are processed.
95.El
96.Pp
97The
98.Fl H ,
99.Fl L
100and
101.Fl P
102options are ignored unless the
103.Fl R
104option is specified.
105In addition, these options override each other and the
106command's actions are determined by the last one specified.
107The default is as if the
108.Fl P
109option had been specified.
110.Pp
111The
112.Fl L
113option cannot be used together with the
114.Fl h
115option.
116.Pp
117The
118.Ar owner
119and
120.Ar group
121operands are both optional, however, one must be specified; alternatively,
122both the owner and group may be specified using a reference
123.Ar rfile
124specified using the
125.Fl Fl reference
126argument.
127If the
128.Ar group
129operand is specified, it must be preceded by a colon (``:'') character.
130.Pp
131The
132.Ar owner
133may be either a user name or a numeric user ID.
134The
135.Ar group
136may be either a group name or a numeric group ID.
137Since it is valid to have a user or group name that is numeric (and
138doesn't have the numeric ID that matches its name) the name lookup
139is always done first.
140Preceding an ID with a ``#'' character will force it to be taken
141as a number.
142.Pp
143The ownership of a file may only be altered by a super-user for
144obvious security reasons.
145.Pp
146Unless invoked by the super-user,
147.Nm
148clears the set-user-id and set-group-id bits on a file to prevent
149accidental or mischievous creation of set-user-id and set-group-id
150programs.
151.Pp
152The
153.Nm
154utility exits 0 on success, and \*[Gt]0 if an error occurs.
155.Sh COMPATIBILITY
156Previous versions of the
157.Nm
158utility used the dot (``.'') character to distinguish the group name.
159This has been changed to be a colon (``:'') character so that user and
160group names may contain the dot character.
161.Sh SEE ALSO
162.Xr chflags 1 ,
163.Xr chgrp 1 ,
164.Xr find 1 ,
165.Xr chown 2 ,
166.Xr lchown 2 ,
167.Xr fts 3 ,
168.Xr symlink 7
169.Sh STANDARDS
170The
171.Nm
172command is expected to be POSIX 1003.2 compliant.
173.Pp
174The
175.Fl v
176option and the use of ``#'' to force a numeric lookup
177are extensions to
178.St -p1003.2 .
179