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