xref: /freebsd/bin/chflags/chflags.1 (revision 59c8e88e72633afbc47a4ace0d2170d00d51f7dc)
1.\"-
2.\" Copyright (c) 1989, 1990, 1993, 1994
3.\"	The Regents of the University of California.  All rights reserved.
4.\"
5.\" This code is derived from software contributed to Berkeley by
6.\" the Institute of Electrical and Electronics Engineers, Inc.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\" 1. Redistributions of source code must retain the above copyright
12.\"    notice, this list of conditions and the following disclaimer.
13.\" 2. Redistributions in binary form must reproduce the above copyright
14.\"    notice, this list of conditions and the following disclaimer in the
15.\"    documentation and/or other materials provided with the distribution.
16.\" 3. Neither the name of the University nor the names of its contributors
17.\"    may be used to endorse or promote products derived from this software
18.\"    without specific prior written permission.
19.\"
20.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30.\" SUCH DAMAGE.
31.\"
32.Dd June 12, 2018
33.Dt CHFLAGS 1
34.Os
35.Sh NAME
36.Nm chflags
37.Nd change file flags
38.Sh SYNOPSIS
39.Nm
40.Op Fl fhvx
41.Oo
42.Fl R
43.Op Fl H | Fl L | Fl P
44.Oc
45.Ar flags
46.Ar
47.Sh DESCRIPTION
48The
49.Nm
50utility modifies the file flags of the listed files
51as specified by the
52.Ar flags
53operand.
54.Pp
55The options are as follows:
56.Bl -tag -width indent
57.It Fl f
58Do not display a diagnostic message if
59.Nm
60could not modify the flags for
61.Va file ,
62nor modify the exit status to reflect such failures.
63.It Fl H
64If the
65.Fl R
66option is specified, symbolic links on the command line are followed
67and hence unaffected by the command.
68(Symbolic links encountered during traversal are not followed.)
69.It Fl h
70If the
71.Ar file
72is a symbolic link,
73change the file flags of the link itself rather than the file to which it points.
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.
82This is the default.
83.It Fl R
84Change the file flags of the file hierarchies rooted in the files,
85instead of just the files themselves.
86Beware of unintentionally matching the
87.Dq Pa ".."
88hard link to the parent directory when using wildcards like
89.Dq Li ".*" .
90.It Fl v
91Cause
92.Nm
93to be verbose, showing filenames as the flags are modified.
94If the
95.Fl v
96option is specified more than once, the old and new flags of the file
97will also be printed, in octal notation.
98.It Fl x
99Do not cross mount points.
100.El
101.Pp
102The flags are specified as an octal number or a comma separated list
103of keywords.
104The following keywords are currently defined:
105.Bl -tag -offset indent -width ".Cm opaque"
106.It Cm arch , archived
107set the archived flag (super-user only)
108.It Cm nodump
109set the nodump flag (owner or super-user only)
110.It Cm opaque
111set the opaque flag (owner or super-user only)
112.It Cm sappnd , sappend
113set the system append-only flag (super-user only)
114.It Cm schg , schange , simmutable
115set the system immutable flag (super-user only)
116.It Cm snapshot
117set the snapshot flag (filesystems do not allow changing this flag)
118.It Cm sunlnk , sunlink
119set the system undeletable flag (super-user only)
120.It Cm uappnd , uappend
121set the user append-only flag (owner or super-user only)
122.It Cm uarch , uarchive
123set the archive flag (owner or super-user only)
124.It Cm uchg , uchange , uimmutable
125set the user immutable flag (owner or super-user only)
126.It Cm uhidden , hidden
127set the hidden file attribute (owner or super-user only)
128.It Cm uoffline , offline
129set the offline file attribute (owner or super-user only)
130.It Cm urdonly , rdonly , readonly
131set the DOS, Windows and CIFS readonly flag (owner or super-user only)
132.It Cm usparse , sparse
133set the sparse file attribute (owner or super-user only)
134.It Cm usystem , system
135set the DOS, Windows and CIFS system flag (owner or super-user only)
136.It Cm ureparse , reparse
137set the Windows reparse point file attribute (owner or super-user only)
138.It Cm uunlnk , uunlink
139set the user undeletable flag (owner or super-user only)
140.El
141.Pp
142Putting the letters
143.Dq Ar no
144before or removing the letters
145.Dq Ar no
146from a keyword causes the flag to be cleared.
147For example:
148.Pp
149.Bl -tag -offset indent -width "nouchg" -compact
150.It Cm nouchg
151clear the user immutable flag (owner or super-user only)
152.It Cm dump
153clear the nodump flag (owner or super-user only)
154.El
155.Pp
156A few of the octal values include:
157.Bl -tag -offset indent -width ".Li 10"
158.It Li 0
159Clear all file flags.
160.It Li 1
161Translates to the
162.Cm nodump
163keyword.
164.It Li 2
165Translates to the
166.Cm uchg
167keyword.
168.It Li 3
169Translates to the
170.Cm uchg , nodump
171keywords.
172.It Li 4
173Translates to the
174.Cm uappnd
175keyword.
176.It Li 10
177Translates to the
178.Cm opaque
179keyword.
180.It Li 20
181translates to the
182.Cm uunlnk
183keyword.
184.El
185.Pp
186Other combinations of keywords may be placed by using
187the octets assigned; however, these are the most notable.
188.Pp
189Unless the
190.Fl H ,
191.Fl L ,
192or
193.Fl h
194options are given,
195.Nm
196on a symbolic link always succeeds and has no effect.
197The
198.Fl H ,
199.Fl L
200and
201.Fl P
202options are ignored unless the
203.Fl R
204option is specified.
205In addition, these options override each other and the
206command's actions are determined by the last one specified.
207.Pp
208You can use "ls -lo" to see the flags of existing files.
209.Pp
210Note that the ability to change certain flags is dependent
211on the current kernel
212.Va securelevel
213setting.
214See
215.Xr security 7
216for more information on this setting.
217.Pp
218If
219.Nm
220receives a
221.Dv SIGINFO
222signal (see the
223.Cm status
224argument for
225.Xr stty 1 ) ,
226then the current filename as well as the old and new flags are displayed.
227.Sh EXIT STATUS
228.Ex -std
229.Sh EXAMPLES
230Recursively clear all flags on files and directories contained within the
231.Fa foobar
232directory hierarchy:
233.Dl Nm Fl R Ar 0 Ar foobar
234.Sh SEE ALSO
235.Xr ls 1 ,
236.Xr chflags 2 ,
237.Xr stat 2 ,
238.Xr fts 3 ,
239.Xr security 7 ,
240.Xr symlink 7
241.Sh HISTORY
242The
243.Nm
244command first appeared in
245.Bx 4.4 .
246.Sh BUGS
247Only a limited number of utilities are
248.Nm
249aware.
250Some of these tools include
251.Xr ls 1 ,
252.Xr cp 1 ,
253.Xr find 1 ,
254.Xr install 1 ,
255.Xr dump 8 ,
256and
257.Xr restore 8 .
258In particular a tool which is not currently
259.Nm
260aware is the
261.Xr pax 1
262utility.
263