xref: /freebsd/bin/chflags/chflags.1 (revision 90aea514c6249118e880d75972d063362f4bf492)
19ddb49cbSWarner Losh.\"-
29b50d902SRodney W. Grimes.\" Copyright (c) 1989, 1990, 1993, 1994
39b50d902SRodney W. Grimes.\"	The Regents of the University of California.  All rights reserved.
49b50d902SRodney W. Grimes.\"
59b50d902SRodney W. Grimes.\" This code is derived from software contributed to Berkeley by
69b50d902SRodney W. Grimes.\" the Institute of Electrical and Electronics Engineers, Inc.
79b50d902SRodney W. Grimes.\"
89b50d902SRodney W. Grimes.\" Redistribution and use in source and binary forms, with or without
99b50d902SRodney W. Grimes.\" modification, are permitted provided that the following conditions
109b50d902SRodney W. Grimes.\" are met:
119b50d902SRodney W. Grimes.\" 1. Redistributions of source code must retain the above copyright
129b50d902SRodney W. Grimes.\"    notice, this list of conditions and the following disclaimer.
139b50d902SRodney W. Grimes.\" 2. Redistributions in binary form must reproduce the above copyright
149b50d902SRodney W. Grimes.\"    notice, this list of conditions and the following disclaimer in the
159b50d902SRodney W. Grimes.\"    documentation and/or other materials provided with the distribution.
16fbbd9655SWarner Losh.\" 3. Neither the name of the University nor the names of its contributors
179b50d902SRodney W. Grimes.\"    may be used to endorse or promote products derived from this software
189b50d902SRodney W. Grimes.\"    without specific prior written permission.
199b50d902SRodney W. Grimes.\"
209b50d902SRodney W. Grimes.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
219b50d902SRodney W. Grimes.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
229b50d902SRodney W. Grimes.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
239b50d902SRodney W. Grimes.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
249b50d902SRodney W. Grimes.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
259b50d902SRodney W. Grimes.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
269b50d902SRodney W. Grimes.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
279b50d902SRodney W. Grimes.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
289b50d902SRodney W. Grimes.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
299b50d902SRodney W. Grimes.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
309b50d902SRodney W. Grimes.\" SUCH DAMAGE.
319b50d902SRodney W. Grimes.\"
32*bc0d1102SEdward Tomasz Napierala.Dd June 12, 2018
339b50d902SRodney W. Grimes.Dt CHFLAGS 1
349b50d902SRodney W. Grimes.Os
359b50d902SRodney W. Grimes.Sh NAME
369b50d902SRodney W. Grimes.Nm chflags
379b50d902SRodney W. Grimes.Nd change file flags
389b50d902SRodney W. Grimes.Sh SYNOPSIS
398fe908efSRuslan Ermilov.Nm
4025d90d5cSBryan Drewery.Op Fl fhvx
419b50d902SRodney W. Grimes.Oo
429b50d902SRodney W. Grimes.Fl R
439b50d902SRodney W. Grimes.Op Fl H | Fl L | Fl P
449b50d902SRodney W. Grimes.Oc
459b50d902SRodney W. Grimes.Ar flags
46dd562b0eSPhilippe Charnier.Ar
479b50d902SRodney W. Grimes.Sh DESCRIPTION
489b50d902SRodney W. GrimesThe
49dd562b0eSPhilippe Charnier.Nm
509b50d902SRodney W. Grimesutility modifies the file flags of the listed files
519b50d902SRodney W. Grimesas specified by the
529b50d902SRodney W. Grimes.Ar flags
539b50d902SRodney W. Grimesoperand.
549b50d902SRodney W. Grimes.Pp
559b50d902SRodney W. GrimesThe options are as follows:
56dd562b0eSPhilippe Charnier.Bl -tag -width indent
571b21ffa6SRobert Watson.It Fl f
581b21ffa6SRobert WatsonDo not display a diagnostic message if
591b21ffa6SRobert Watson.Nm
601b21ffa6SRobert Watsoncould not modify the flags for
611b21ffa6SRobert Watson.Va file ,
621b21ffa6SRobert Watsonnor modify the exit status to reflect such failures.
639b50d902SRodney W. Grimes.It Fl H
649b50d902SRodney W. GrimesIf the
659b50d902SRodney W. Grimes.Fl R
66ad34caceSSteven Hartlandoption is specified, symbolic links on the command line are followed
67ad34caceSSteven Hartlandand hence unaffected by the command.
68ad34caceSSteven Hartland(Symbolic links encountered during traversal are not followed.)
697e81a152SDima Dorfman.It Fl h
707e81a152SDima DorfmanIf the
717e81a152SDima Dorfman.Ar file
727e81a152SDima Dorfmanis a symbolic link,
732bb42822SPawel Jakub Dawidekchange the file flags of the link itself rather than the file to which it points.
749b50d902SRodney W. Grimes.It Fl L
759b50d902SRodney W. GrimesIf the
769b50d902SRodney W. Grimes.Fl R
779b50d902SRodney W. Grimesoption is specified, all symbolic links are followed.
789b50d902SRodney W. Grimes.It Fl P
799b50d902SRodney W. GrimesIf the
809b50d902SRodney W. Grimes.Fl R
819b50d902SRodney W. Grimesoption is specified, no symbolic links are followed.
8295a09b05SRuslan ErmilovThis is the default.
839b50d902SRodney W. Grimes.It Fl R
84ad34caceSSteven HartlandChange the file flags of the file hierarchies rooted in the files,
85ad34caceSSteven Hartlandinstead of just the files themselves.
86ad34caceSSteven HartlandBeware of unintentionally matching the
87ad34caceSSteven Hartland.Dq Pa ".."
88ad34caceSSteven Hartlandhard link to the parent directory when using wildcards like
89ad34caceSSteven Hartland.Dq Li ".*" .
901b21ffa6SRobert Watson.It Fl v
911b21ffa6SRobert WatsonCause
921b21ffa6SRobert Watson.Nm
931b21ffa6SRobert Watsonto be verbose, showing filenames as the flags are modified.
941b21ffa6SRobert WatsonIf the
951b21ffa6SRobert Watson.Fl v
961b21ffa6SRobert Watsonoption is specified more than once, the old and new flags of the file
971b21ffa6SRobert Watsonwill also be printed, in octal notation.
9825d90d5cSBryan Drewery.It Fl x
9925d90d5cSBryan DreweryDo not cross mount points.
1009b50d902SRodney W. Grimes.El
1019b50d902SRodney W. Grimes.Pp
102ec9247d5SJohn PolstraThe flags are specified as an octal number or a comma separated list
103ec9247d5SJohn Polstraof keywords.
1049b50d902SRodney W. GrimesThe following keywords are currently defined:
10564f9e6adSTom Rhodes.Bl -tag -offset indent -width ".Cm opaque"
10664f9e6adSTom Rhodes.It Cm arch , archived
1079b88faecSRuslan Ermilovset the archived flag (super-user only)
10864f9e6adSTom Rhodes.It Cm nodump
1099b88faecSRuslan Ermilovset the nodump flag (owner or super-user only)
1107da1a731SKenneth D. Merry.It Cm opaque
1117da1a731SKenneth D. Merryset the opaque flag (owner or super-user only)
11264f9e6adSTom Rhodes.It Cm sappnd , sappend
1139b88faecSRuslan Ermilovset the system append-only flag (super-user only)
11464f9e6adSTom Rhodes.It Cm schg , schange , simmutable
1159b88faecSRuslan Ermilovset the system immutable flag (super-user only)
1167da1a731SKenneth D. Merry.It Cm snapshot
1177da1a731SKenneth D. Merryset the snapshot flag (filesystems do not allow changing this flag)
11864f9e6adSTom Rhodes.It Cm sunlnk , sunlink
1199b88faecSRuslan Ermilovset the system undeletable flag (super-user only)
12064f9e6adSTom Rhodes.It Cm uappnd , uappend
1219b88faecSRuslan Ermilovset the user append-only flag (owner or super-user only)
1227da1a731SKenneth D. Merry.It Cm uarch , uarchive
1237da1a731SKenneth D. Merryset the archive flag (owner or super-user only)
12464f9e6adSTom Rhodes.It Cm uchg , uchange , uimmutable
1259b88faecSRuslan Ermilovset the user immutable flag (owner or super-user only)
1267da1a731SKenneth D. Merry.It Cm uhidden , hidden
1277da1a731SKenneth D. Merryset the hidden file attribute (owner or super-user only)
1287da1a731SKenneth D. Merry.It Cm uoffline , offline
1297da1a731SKenneth D. Merryset the offline file attribute (owner or super-user only)
1307da1a731SKenneth D. Merry.It Cm urdonly , rdonly , readonly
1317da1a731SKenneth D. Merryset the DOS, Windows and CIFS readonly flag (owner or super-user only)
1327da1a731SKenneth D. Merry.It Cm usparse , sparse
1337da1a731SKenneth D. Merryset the sparse file attribute (owner or super-user only)
1347da1a731SKenneth D. Merry.It Cm usystem , system
1357da1a731SKenneth D. Merryset the DOS, Windows and CIFS system flag (owner or super-user only)
1367da1a731SKenneth D. Merry.It Cm ureparse , reparse
1377da1a731SKenneth D. Merryset the Windows reparse point file attribute (owner or super-user only)
13864f9e6adSTom Rhodes.It Cm uunlnk , uunlink
1399b88faecSRuslan Ermilovset the user undeletable flag (owner or super-user only)
1409b88faecSRuslan Ermilov.El
1419b50d902SRodney W. Grimes.Pp
1429b50d902SRodney W. GrimesPutting the letters
1439b88faecSRuslan Ermilov.Dq Ar no
144ab46875aSJohan Karlssonbefore or removing the letters
145ab46875aSJohan Karlsson.Dq Ar no
146ab46875aSJohan Karlssonfrom a keyword causes the flag to be cleared.
1479b50d902SRodney W. GrimesFor example:
148ab46875aSJohan Karlsson.Pp
149ab46875aSJohan Karlsson.Bl -tag -offset indent -width "nouchg" -compact
15064f9e6adSTom Rhodes.It Cm nouchg
151ab46875aSJohan Karlssonclear the user immutable flag (owner or super-user only)
15264f9e6adSTom Rhodes.It Cm dump
153ab46875aSJohan Karlssonclear the nodump flag (owner or super-user only)
1549b88faecSRuslan Ermilov.El
1559b50d902SRodney W. Grimes.Pp
1566de681c6STom RhodesA few of the octal values include:
1574d5ea497STom Rhodes.Bl -tag -offset indent -width ".Li 10"
1586de681c6STom Rhodes.It Li 0
1596de681c6STom RhodesClear all file flags.
1606de681c6STom Rhodes.It Li 1
1616de681c6STom RhodesTranslates to the
1624d5ea497STom Rhodes.Cm nodump
1636de681c6STom Rhodeskeyword.
1646de681c6STom Rhodes.It Li 2
1656de681c6STom RhodesTranslates to the
1664d5ea497STom Rhodes.Cm uchg
1676de681c6STom Rhodeskeyword.
1686de681c6STom Rhodes.It Li 3
1696de681c6STom RhodesTranslates to the
1704d5ea497STom Rhodes.Cm uchg , nodump
1716de681c6STom Rhodeskeywords.
1726de681c6STom Rhodes.It Li 4
1736de681c6STom RhodesTranslates to the
1744d5ea497STom Rhodes.Cm uappnd
1756de681c6STom Rhodeskeyword.
1766de681c6STom Rhodes.It Li 10
1776de681c6STom RhodesTranslates to the
1784d5ea497STom Rhodes.Cm opaque
1796de681c6STom Rhodeskeyword.
1806de681c6STom Rhodes.It Li 20
1816de681c6STom Rhodestranslates to the
1824d5ea497STom Rhodes.Cm uunlnk
1836de681c6STom Rhodeskeyword.
1846de681c6STom Rhodes.El
1856de681c6STom Rhodes.Pp
1866de681c6STom RhodesOther combinations of keywords may be placed by using
1876de681c6STom Rhodesthe octets assigned; however, these are the most notable.
1886de681c6STom Rhodes.Pp
1897e81a152SDima DorfmanUnless the
1907e81a152SDima Dorfman.Fl H ,
1917e81a152SDima Dorfman.Fl L ,
1929b50d902SRodney W. Grimesor
1937e81a152SDima Dorfman.Fl h
1947e81a152SDima Dorfmanoptions are given,
195dd562b0eSPhilippe Charnier.Nm
1969b50d902SRodney W. Grimeson a symbolic link always succeeds and has no effect.
1979b50d902SRodney W. GrimesThe
1989b50d902SRodney W. Grimes.Fl H ,
1999b50d902SRodney W. Grimes.Fl L
2009b50d902SRodney W. Grimesand
2019b50d902SRodney W. Grimes.Fl P
2029b50d902SRodney W. Grimesoptions are ignored unless the
2039b50d902SRodney W. Grimes.Fl R
2049b50d902SRodney W. Grimesoption is specified.
2059b50d902SRodney W. GrimesIn addition, these options override each other and the
2069b50d902SRodney W. Grimescommand's actions are determined by the last one specified.
2079b50d902SRodney W. Grimes.Pp
208601fc2b9SPhilippe CharnierYou can use "ls -lo" to see the flags of existing files.
2096de681c6STom Rhodes.Pp
2106de681c6STom RhodesNote that the ability to change certain flags is dependent
2116de681c6STom Rhodeson the current kernel
2124d5ea497STom Rhodes.Va securelevel
2136de681c6STom Rhodessetting.
2146de681c6STom RhodesSee
2156de681c6STom Rhodes.Xr security 7
2166de681c6STom Rhodesfor more information on this setting.
217fdee29d7SBryan Drewery.Pp
218fdee29d7SBryan DreweryIf
219fdee29d7SBryan Drewery.Nm
220fdee29d7SBryan Dreweryreceives a
221fdee29d7SBryan Drewery.Dv SIGINFO
222fdee29d7SBryan Drewerysignal (see the
223fdee29d7SBryan Drewery.Cm status
224fdee29d7SBryan Dreweryargument for
225fdee29d7SBryan Drewery.Xr stty 1 ) ,
226fdee29d7SBryan Drewerythen the current filename as well as the old and new flags are displayed.
2276fca4c7cSRuslan Ermilov.Sh EXIT STATUS
228d628d776SRuslan Ermilov.Ex -std
229*bc0d1102SEdward Tomasz Napierala.Sh EXAMPLES
230*bc0d1102SEdward Tomasz NapieralaRecursively clear all flags on files and directories contained within the
231*bc0d1102SEdward Tomasz Napierala.Fa foobar
232*bc0d1102SEdward Tomasz Napieraladirectory hierarchy:
233*bc0d1102SEdward Tomasz Napierala.Dl Nm Fl R Ar 0 Ar foobar
2349b50d902SRodney W. Grimes.Sh SEE ALSO
235601fc2b9SPhilippe Charnier.Xr ls 1 ,
2369b50d902SRodney W. Grimes.Xr chflags 2 ,
2379b50d902SRodney W. Grimes.Xr stat 2 ,
2389b50d902SRodney W. Grimes.Xr fts 3 ,
2396de681c6STom Rhodes.Xr security 7 ,
2409b50d902SRodney W. Grimes.Xr symlink 7
2417b020a2fSRuslan Ermilov.Sh HISTORY
2427b020a2fSRuslan ErmilovThe
2437b020a2fSRuslan Ermilov.Nm
2447b020a2fSRuslan Ermilovcommand first appeared in
2457b020a2fSRuslan Ermilov.Bx 4.4 .
24651cf6329STom Rhodes.Sh BUGS
24751cf6329STom RhodesOnly a limited number of utilities are
24851cf6329STom Rhodes.Nm
24951cf6329STom Rhodesaware.
25061001d75STom RhodesSome of these tools include
25151cf6329STom Rhodes.Xr ls 1 ,
25251cf6329STom Rhodes.Xr cp 1 ,
25351cf6329STom Rhodes.Xr find 1 ,
25461001d75STom Rhodes.Xr install 1 ,
25551cf6329STom Rhodes.Xr dump 8 ,
25651cf6329STom Rhodesand
25751cf6329STom Rhodes.Xr restore 8 .
25861001d75STom RhodesIn particular a tool which is not currently
25951cf6329STom Rhodes.Nm
26061001d75STom Rhodesaware is the
26161001d75STom Rhodes.Xr pax 1
26261001d75STom Rhodesutility.
263