xref: /openbsd/bin/chmod/chown.8 (revision 09467b48)
1.\"	$OpenBSD: chown.8,v 1.23 2019/09/06 19:25:08 schwarze 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: September 6 2019 $
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 : 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
67Treat symbolic links like other files: modify links instead of
68following them.
69The
70.Fl h
71and
72.Fl R
73options are mutually exclusive.
74.It Fl L
75If the
76.Fl R
77option is specified, all symbolic links are followed.
78.It Fl P
79If the
80.Fl R
81option is specified, no symbolic links are followed.
82.It Fl R
83Recurse.
84Where
85.Ar file
86is a directory,
87change the user ID and/or the group ID of the directory
88and all the files and directories in the file hierarchy below it.
89.El
90.Pp
91The
92.Fl H ,
93.Fl L ,
94and
95.Fl P
96options are ignored unless the
97.Fl R
98option is specified;
99if none of them are given,
100the default is to not follow symbolic links.
101In addition, these options override each other and the
102command's actions are determined by the last one specified.
103.Pp
104The
105.Ar owner
106and
107.Ar group
108operands are both optional; however, one must be specified.
109If the
110.Ar group
111operand is specified, it must be preceded by a colon
112.Pq Sq \&:
113character.
114.Pp
115The
116.Ar owner
117may be either a numeric user ID or a user name.
118If a user name is also a numeric user ID, the operand is used as a
119user name.
120The
121.Ar group
122may be either a numeric group ID or a group name.
123If a group name is also a numeric group ID, the operand is used as a
124group name.
125.Pp
126By default,
127.Nm
128clears the set-user-ID and set-group-ID bits on the file
129to prevent accidental or mischievous creation of
130set-user-ID and set-group-ID programs.
131This behaviour can be overridden by setting the
132.Xr sysctl 8
133variable
134.Va fs.posix.setuid
135to zero.
136.Pp
137Only the superuser is permitted to change the owner of a file.
138.Sh EXIT STATUS
139.Ex -std chown
140.Sh SEE ALSO
141.Xr chgrp 1 ,
142.Xr find 1 ,
143.Xr chown 2 ,
144.Xr fts_open 3 ,
145.Xr symlink 7
146.Sh STANDARDS
147The
148.Nm
149utility is compliant with the
150.St -p1003.1-2008
151specification.
152.Pp
153The ability to specify
154.Ar group
155without
156.Ar owner
157is an extension to that specification.
158.Pp
159Some
160.Pf non- Bx
161systems may allow the (non-privileged) owner of a file to change
162its ownership.
163.Pp
164Previous versions of the
165.Nm
166utility used the dot
167.Pq Sq \&.
168character to distinguish the group name.
169This was changed when the utility was first standardised in
170.St -p1003.2-92
171to be a colon
172.Pq Sq \&:
173character to allow user and group names to contain the dot
174character, though the dot separator still remains supported
175due to widely required backwards compatibility.
176.Sh HISTORY
177A
178.Nm
179command appeared in
180.At v1 .
181