xref: /openbsd/bin/chmod/chflags.1 (revision 264ca280)
1.\"	$OpenBSD: chflags.1,v 1.16 2015/12/31 23:38:16 guenther 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. Neither the name of the University nor the names of its contributors
19.\"    may be used to endorse or promote products derived from this software
20.\"    without specific prior written permission.
21.\"
22.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32.\" SUCH DAMAGE.
33.\"
34.\"	@(#)chflags.1	8.4 (Berkeley) 5/2/95
35.\"
36.Dd $Mdocdate: December 31 2015 $
37.Dt CHFLAGS 1
38.Os
39.Sh NAME
40.Nm chflags
41.Nd change file flags
42.Sh SYNOPSIS
43.Nm chflags
44.Op Fl h
45.Oo
46.Fl R
47.Op Fl H | L | P
48.Oc
49.Ar flags
50.Ar
51.Sh DESCRIPTION
52The
53.Nm
54utility modifies the file flags of the listed files
55as specified by the
56.Ar flags
57operand.
58The
59.Ar flags
60of a file dictate special restrictions beyond those enforced by its
61mode/permissions.
62Only the superuser can change the user flags on block and
63character devices.
64.Pp
65You can use
66.Ic ls -lo
67to see the flags of existing files.
68.Pp
69The options are as follows:
70.Bl -tag -width Ds
71.It Fl H
72If the
73.Fl R
74option is also specified, symbolic links on the command line are followed.
75Symbolic links encountered in the tree traversal are not followed.
76.It Fl h
77Treat symbolic links like other files: modify links instead of
78following them.
79The
80.Fl h
81and
82.Fl R
83options are mutually exclusive.
84.It Fl L
85If the
86.Fl R
87option is also specified, all symbolic links are followed.
88.It Fl P
89If the
90.Fl R
91option is also specified, no symbolic links are followed.
92.It Fl R
93Recurse.
94Where
95.Ar file
96is a directory,
97change the flags of the directory and all the files and directories
98in the file hierarchy below it.
99.El
100.Pp
101Flags are a comma separated list of keywords.
102The following keywords are currently defined:
103.Bd -literal -offset indent
104arch	set the archived flag (superuser only)
105nodump	set the nodump flag (owner or superuser only)
106sappnd	set the system append-only flag (superuser only)
107schg	set the system immutable flag (superuser only)
108uappnd	set the user append-only flag (owner or superuser only)
109uchg	set the user immutable flag (owner or superuser only)
110.Ed
111.Pp
112The
113.Dq arch
114flag is for compatibility only,
115and currently has no effect.
116.Pp
117A file with the
118.Dq nodump
119flag set will by default only be backed up by
120.Xr dump 8
121during full backups.
122The
123.Fl h
124option of
125.Xr dump 8
126can be used to alter this.
127.Pp
128An immutable file may not be changed, moved, or deleted.
129An append-only file is immutable except that data may be appended to it.
130.Pp
131The
132superuser-settable
133.Dq sappnd
134and
135.Dq schg
136flags can be set at any time, but may only be cleared when the system is
137running at security level 0 or \-1
138(insecure or permanently insecure mode, respectively).
139For more information on setting the system security level,
140see
141.Xr securelevel 7 .
142.Pp
143Putting the letters
144.Dq no
145before a flag name causes the flag to be turned off.
146For example:
147.Pp
148.Dl nouchg	the immutable bit should be cleared
149.Pp
150The
151.Fl H ,
152.Fl L ,
153and
154.Fl P
155options are ignored unless the
156.Fl R
157option is specified.
158In addition, these options override each other and the
159command's actions are determined by the last one specified.
160.Sh EXIT STATUS
161.Ex -std chflags
162.Sh SEE ALSO
163.Xr ls 1 ,
164.Xr chflags 2 ,
165.Xr stat 2 ,
166.Xr fts 3 ,
167.Xr securelevel 7 ,
168.Xr symlink 7 ,
169.Xr dump 8
170.Sh HISTORY
171The
172.Nm
173command first appeared in
174.Bx 4.4 .
175