xref: /freebsd/bin/chflags/chflags.1 (revision 5ab1c5846ff41be24b1f6beb0317bf8258cd4409)
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.\"	@(#)chflags.1	8.4 (Berkeley) 5/2/95
33.\" $FreeBSD$
34.\"
35.Dd June 12, 2018
36.Dt CHFLAGS 1
37.Os
38.Sh NAME
39.Nm chflags
40.Nd change file flags
41.Sh SYNOPSIS
42.Nm
43.Op Fl fhvx
44.Oo
45.Fl R
46.Op Fl H | Fl L | Fl P
47.Oc
48.Ar flags
49.Ar
50.Sh DESCRIPTION
51The
52.Nm
53utility modifies the file flags of the listed files
54as specified by the
55.Ar flags
56operand.
57.Pp
58The options are as follows:
59.Bl -tag -width indent
60.It Fl f
61Do not display a diagnostic message if
62.Nm
63could not modify the flags for
64.Va file ,
65nor modify the exit status to reflect such failures.
66.It Fl H
67If the
68.Fl R
69option is specified, symbolic links on the command line are followed
70and hence unaffected by the command.
71(Symbolic links encountered during traversal are not followed.)
72.It Fl h
73If the
74.Ar file
75is a symbolic link,
76change the file flags of the link itself rather than the file to which it points.
77.It Fl L
78If the
79.Fl R
80option is specified, all symbolic links are followed.
81.It Fl P
82If the
83.Fl R
84option is specified, no symbolic links are followed.
85This is the default.
86.It Fl R
87Change the file flags of the file hierarchies rooted in the files,
88instead of just the files themselves.
89Beware of unintentionally matching the
90.Dq Pa ".."
91hard link to the parent directory when using wildcards like
92.Dq Li ".*" .
93.It Fl v
94Cause
95.Nm
96to be verbose, showing filenames as the flags are modified.
97If the
98.Fl v
99option is specified more than once, the old and new flags of the file
100will also be printed, in octal notation.
101.It Fl x
102Do not cross mount points.
103.El
104.Pp
105The flags are specified as an octal number or a comma separated list
106of keywords.
107The following keywords are currently defined:
108.Bl -tag -offset indent -width ".Cm opaque"
109.It Cm arch , archived
110set the archived flag (super-user only)
111.It Cm nodump
112set the nodump flag (owner or super-user only)
113.It Cm opaque
114set the opaque flag (owner or super-user only)
115.It Cm sappnd , sappend
116set the system append-only flag (super-user only)
117.It Cm schg , schange , simmutable
118set the system immutable flag (super-user only)
119.It Cm snapshot
120set the snapshot flag (filesystems do not allow changing this flag)
121.It Cm sunlnk , sunlink
122set the system undeletable flag (super-user only)
123.It Cm uappnd , uappend
124set the user append-only flag (owner or super-user only)
125.It Cm uarch , uarchive
126set the archive flag (owner or super-user only)
127.It Cm uchg , uchange , uimmutable
128set the user immutable flag (owner or super-user only)
129.It Cm uhidden , hidden
130set the hidden file attribute (owner or super-user only)
131.It Cm uoffline , offline
132set the offline file attribute (owner or super-user only)
133.It Cm urdonly , rdonly , readonly
134set the DOS, Windows and CIFS readonly flag (owner or super-user only)
135.It Cm usparse , sparse
136set the sparse file attribute (owner or super-user only)
137.It Cm usystem , system
138set the DOS, Windows and CIFS system flag (owner or super-user only)
139.It Cm ureparse , reparse
140set the Windows reparse point file attribute (owner or super-user only)
141.It Cm uunlnk , uunlink
142set the user undeletable flag (owner or super-user only)
143.El
144.Pp
145Putting the letters
146.Dq Ar no
147before or removing the letters
148.Dq Ar no
149from a keyword causes the flag to be cleared.
150For example:
151.Pp
152.Bl -tag -offset indent -width "nouchg" -compact
153.It Cm nouchg
154clear the user immutable flag (owner or super-user only)
155.It Cm dump
156clear the nodump flag (owner or super-user only)
157.El
158.Pp
159A few of the octal values include:
160.Bl -tag -offset indent -width ".Li 10"
161.It Li 0
162Clear all file flags.
163.It Li 1
164Translates to the
165.Cm nodump
166keyword.
167.It Li 2
168Translates to the
169.Cm uchg
170keyword.
171.It Li 3
172Translates to the
173.Cm uchg , nodump
174keywords.
175.It Li 4
176Translates to the
177.Cm uappnd
178keyword.
179.It Li 10
180Translates to the
181.Cm opaque
182keyword.
183.It Li 20
184translates to the
185.Cm uunlnk
186keyword.
187.El
188.Pp
189Other combinations of keywords may be placed by using
190the octets assigned; however, these are the most notable.
191.Pp
192Unless the
193.Fl H ,
194.Fl L ,
195or
196.Fl h
197options are given,
198.Nm
199on a symbolic link always succeeds and has no effect.
200The
201.Fl H ,
202.Fl L
203and
204.Fl P
205options are ignored unless the
206.Fl R
207option is specified.
208In addition, these options override each other and the
209command's actions are determined by the last one specified.
210.Pp
211You can use "ls -lo" to see the flags of existing files.
212.Pp
213Note that the ability to change certain flags is dependent
214on the current kernel
215.Va securelevel
216setting.
217See
218.Xr security 7
219for more information on this setting.
220.Pp
221If
222.Nm
223receives a
224.Dv SIGINFO
225signal (see the
226.Cm status
227argument for
228.Xr stty 1 ) ,
229then the current filename as well as the old and new flags are displayed.
230.Sh EXIT STATUS
231.Ex -std
232.Sh EXAMPLES
233Recursively clear all flags on files and directories contained within the
234.Fa foobar
235directory hierarchy:
236.Dl Nm Fl R Ar 0 Ar foobar
237.Sh SEE ALSO
238.Xr ls 1 ,
239.Xr chflags 2 ,
240.Xr stat 2 ,
241.Xr fts 3 ,
242.Xr security 7 ,
243.Xr symlink 7
244.Sh HISTORY
245The
246.Nm
247command first appeared in
248.Bx 4.4 .
249.Sh BUGS
250Only a limited number of utilities are
251.Nm
252aware.
253Some of these tools include
254.Xr ls 1 ,
255.Xr cp 1 ,
256.Xr find 1 ,
257.Xr install 1 ,
258.Xr dump 8 ,
259and
260.Xr restore 8 .
261In particular a tool which is not currently
262.Nm
263aware is the
264.Xr pax 1
265utility.
266