xref: /openbsd/bin/chmod/chown.8 (revision 8529ddd3)
1.\"	$OpenBSD: chown.8,v 1.18 2014/01/23 08:18:12 jmc Exp $
2.\"
3.\" Copyright (c) 1990, 1991, 1993, 1994
4.\"	The Regents of the University of California.  All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\"    notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice, this list of conditions and the following disclaimer in the
13.\"    documentation and/or other materials provided with the distribution.
14.\" 3. Neither the name of the University nor the names of its contributors
15.\"    may be used to endorse or promote products derived from this software
16.\"    without specific prior written permission.
17.\"
18.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28.\" SUCH DAMAGE.
29.\"
30.\"     from: @(#)chown.8	8.3 (Berkeley) 3/31/94
31.\"
32.Dd $Mdocdate: January 23 2014 $
33.Dt CHOWN 8
34.Os
35.Sh NAME
36.Nm chown
37.Nd change file owner and group
38.Sh SYNOPSIS
39.Nm chown
40.Op Fl h
41.Oo
42.Fl R
43.Op Fl H | L | P
44.Oc
45.Ar owner Ns Op : Ns Ar group
46.Ar
47.Nm chown
48.Op Fl h
49.Oo
50.Fl R
51.Op Fl H | L | P
52.Oc
53.Pf : Ns Ar group
54.Ar
55.Sh DESCRIPTION
56.Nm
57sets the user ID and/or the group ID of the specified files.
58.Pp
59The options are as follows:
60.Bl -tag -width Ds
61.It Fl H
62If the
63.Fl R
64option is specified, symbolic links on the command line are followed.
65Symbolic links encountered in the tree traversal are not followed.
66.It Fl h
67Change the user ID and/or the group ID on symbolic links.
68The
69.Fl R
70and
71.Fl h
72options are mutually exclusive.
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
82Recurse.
83Where
84.Ar file
85is a directory,
86change the user ID and/or the group ID of the directory
87and all the files and directories in the file hierarchy below it.
88.El
89.Pp
90The
91.Fl H ,
92.Fl L ,
93and
94.Fl P
95options are ignored unless the
96.Fl R
97option is specified;
98if none of them are given,
99the default is to not follow symbolic links.
100In addition, these options override each other and the
101command's actions are determined by the last one specified.
102.Pp
103The
104.Ar owner
105and
106.Ar group
107operands are both optional; however, one must be specified.
108If the
109.Ar group
110operand is specified, it must be preceded by a colon
111.Pq Sq \&:
112character.
113.Pp
114The
115.Ar owner
116may be either a numeric user ID or a user name.
117If a user name is also a numeric user ID, the operand is used as a
118user name.
119The
120.Ar group
121may be either a numeric group ID or a group name.
122If a group name is also a numeric group ID, the operand is used as a
123group name.
124.Pp
125By default,
126.Nm
127clears the set-user-ID and set-group-ID bits on the file
128to prevent accidental or mischievous creation of
129set-user-ID and set-group-ID programs.
130This behaviour can be overridden by setting the
131.Xr sysctl 8
132variable
133.Va fs.posix.setuid
134to zero.
135.Pp
136Only the superuser is permitted to change the owner of a file.
137.Sh EXIT STATUS
138.Ex -std chown
139.Sh SEE ALSO
140.Xr chgrp 1 ,
141.Xr find 1 ,
142.Xr chown 2 ,
143.Xr fts 3 ,
144.Xr symlink 7
145.Sh STANDARDS
146The
147.Nm
148utility is compliant with the
149.St -p1003.1-2008
150specification.
151.Pp
152The ability to specify
153.Ar group
154without
155.Ar owner
156is an extension to that specification.
157.Pp
158Some
159.Pf non- Bx
160systems may allow the (non-privileged) owner of a file to change
161its ownership.
162.Pp
163Previous versions of the
164.Nm
165utility used the dot
166.Pq Sq \&.
167character to distinguish the group name.
168This has been changed to be a colon
169.Pq Sq \&:
170character so that user and
171group names may contain the dot character.
172