xref: /openbsd/bin/chmod/chflags.1 (revision 78b63d65)
1.\"	$OpenBSD: chflags.1,v 1.2 2000/11/09 23:47:14 aaron Exp $
2.\"	$NetBSD: chflags.1,v 1.4 1995/08/31 22:50:22 jtc Exp $
3.\"
4.\" Copyright (c) 1989, 1990, 1993, 1994
5.\"	The Regents of the University of California.  All rights reserved.
6.\"
7.\" This code is derived from software contributed to Berkeley by
8.\" the Institute of Electrical and Electronics Engineers, Inc.
9.\"
10.\" Redistribution and use in source and binary forms, with or without
11.\" modification, are permitted provided that the following conditions
12.\" are met:
13.\" 1. Redistributions of source code must retain the above copyright
14.\"    notice, this list of conditions and the following disclaimer.
15.\" 2. Redistributions in binary form must reproduce the above copyright
16.\"    notice, this list of conditions and the following disclaimer in the
17.\"    documentation and/or other materials provided with the distribution.
18.\" 3. All advertising materials mentioning features or use of this software
19.\"    must display the following acknowledgement:
20.\"	This product includes software developed by the University of
21.\"	California, Berkeley and its contributors.
22.\" 4. Neither the name of the University nor the names of its contributors
23.\"    may be used to endorse or promote products derived from this software
24.\"    without specific prior written permission.
25.\"
26.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36.\" SUCH DAMAGE.
37.\"
38.\"	@(#)chflags.1	8.4 (Berkeley) 5/2/95
39.\"
40.Dd May 2, 1995
41.Dt CHFLAGS 1
42.Os
43.Sh NAME
44.Nm chflags
45.Nd change file flags
46.Sh SYNOPSIS
47.Nm chflags
48.Oo
49.Fl R
50.Op Fl H | Fl L | Fl P
51.Oc
52.Ar flags
53.Ar file Op Ar ...
54.Sh DESCRIPTION
55The
56.Nm
57utility modifies the file flags of the listed files
58as specified by the
59.Ar flags
60operand.
61The
62.Ar flags
63of a file dictate special restrictions beyond those enforced by its
64mode/permissions.
65.Pp
66The options are as follows:
67.Bl -tag -width Ds
68.It Fl R
69Recursively descend through any specified directory arguments.
70Change the flags of the file hierarchies rooted
71in the files instead of just the files themselves.
72.It Fl H
73If the
74.Fl R
75option is also specified, symbolic links on the command line are followed.
76(Symbolic links encountered in the tree traversal are not followed.)
77.It Fl L
78If the
79.Fl R
80option is also specified, all symbolic links are followed.
81.It Fl P
82If the
83.Fl R
84option is also specified, no symbolic links are followed.
85.El
86.Pp
87Flags are a comma separated list of keywords.
88The following keywords are currently defined:
89.Bd -literal -offset indent compact
90arch	set the archived flag
91opaque	set the opaque flag (owner or superuser only)
92nodump	set the nodump flag (owner or superuser only)
93sappnd	set the system append-only flag (superuser only)
94schg	set the system immutable flag (superuser only)
95uappnd	set the user append-only flag (owner or superuser only)
96uchg	set the user immutable flag (owner or superuser only)
97.Ed
98.Pp
99An immutable file may not be changed, moved, or deleted.
100An append-only file is immutable except that data may be appended to it.
101.Pp
102Putting the letters
103.Dq no
104before a flag name causes the flag to be turned off.
105For example:
106.Bd -literal -offset indent compact
107nouchg	the immutable bit should be cleared
108.Ed
109.Pp
110The
111superuser-settable
112.Dq sappnd
113and
114.Dq schg
115flags can be set at any time, but may only be cleared when the system is
116running at security level 0 or -1 (insecure or permanently insecure mode,
117respectively).
118The securelevel is normally set to 0, for example, when
119running in single-user mode.
120.Pp
121Symbolic links do not have flags, so unless the
122.Fl H
123or
124.Fl L
125option is set,
126.Nm
127on a symbolic link always succeeds and has no effect.
128The
129.Fl H ,
130.Fl L ,
131and
132.Fl P
133options are ignored unless the
134.Fl R
135option is specified.
136In addition, these options override each other and the
137command's actions are determined by the last one specified.
138.Pp
139Only the superuser can change the user flags on block and
140character devices.
141.Pp
142You can use
143.Ic ls -lo
144to see the flags of existing files.
145.Pp
146The
147.Nm
148utility exits 0 on success or >0 if an error occurred.
149.Sh SEE ALSO
150.Xr ls 1 ,
151.Xr chflags 2 ,
152.Xr stat 2 ,
153.Xr fts 3 ,
154.Xr symlink 7
155.Sh HISTORY
156The
157.Nm
158command first appeared in
159.Bx 4.4 .
160