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