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: src/bin/chflags/chflags.1,v 1.30 2008/03/09 12:10:24 rwatson Exp $ 34.\" $DragonFly: src/usr.bin/chflags/chflags.1,v 1.8 2008/11/12 15:18:26 swildner Exp $ 35.\" 36.Dd November 11, 2008 37.Dt CHFLAGS 1 38.Os 39.Sh NAME 40.Nm chflags 41.Nd change file flags 42.Sh SYNOPSIS 43.Nm 44.Op Fl fhv 45.Oo 46.Fl R 47.Op Fl H | Fl L | Fl P 48.Oc 49.Ar flags 50.Ar 51.Sh DESCRIPTION 52The 53.Nm 54utility modifies the file flags of the listed files 55as specified by the 56.Ar flags 57operand. 58.Pp 59The options are as follows: 60.Bl -tag -width indent 61.It Fl f 62Do not display a diagnostic message if 63.Nm 64could not modify the flags for 65.Va file , 66nor modify the exit status to reflect such failures. 67.It Fl H 68If the 69.Fl R 70option is specified, symbolic links on the command line are followed. 71(Symbolic links encountered in the tree 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 77it points. 78.It Fl L 79If the 80.Fl R 81option is specified, all symbolic links are followed. 82.It Fl P 83If the 84.Fl R 85option is specified, no symbolic links are followed. 86This is the default. 87.It Fl R 88Change the file flags for the file hierarchies rooted 89in the files instead of just the files themselves. 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.El 99.Pp 100The flags are specified as an octal number or a comma separated list 101of keywords. 102The following keywords are currently defined: 103.Bl -tag -offset indent -width ".Cm nouhistory" 104.It Cm arch , archived 105set the archived flag (super-user only) 106.It Cm opaque 107set the opaque flag (owner or super-user only) 108.It Cm nodump 109set the nodump flag (owner or super-user only) 110.It Cm noshistory 111set the system nohistory flag (super-user only) 112.It Cm nouhistory , nohistory 113set the user nohistory 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 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 uchg , uchange , uimmutable 123set the user immutable flag (owner or super-user only) 124.It Cm uunlnk , uunlink 125set the user undeletable flag (owner or super-user only) 126.It Cm cache , ucache 127control the data 128.Xr swapcache 8 129(recursive, does not cross mounts) (owner or super-user only) 130.It Cm noscache 131control the data 132.Xr swapcache 8 133(recursive, does not cross mounts) (super-user only) 134.El 135.Pp 136If a 137.Dq Cm no 138prefix is added or removed from a keyword, the meaning is negated. 139For example: 140.Pp 141.Bl -tag -offset indent -width "nouchg" -compact 142.It Cm nouchg 143clear the user immutable flag (owner or super-user only) 144.It Cm dump 145clear the nodump flag (owner or super-user only) 146.El 147.Pp 148A few of the octal values include: 149.Bl -tag -offset indent -width ".Li 10" 150.It Li 0 151Clear all file flags. 152.It Li 1 153Translates to the 154.Cm nodump 155keyword. 156.It Li 2 157Translates to the 158.Cm uchg 159keyword. 160.It Li 3 161Translates to the 162.Cm uchg , nodump 163keywords. 164.It Li 4 165Translates to the 166.Cm uappnd 167keyword. 168.It Li 10 169Translates to the 170.Cm opaque 171keyword. 172.It Li 20 173translates to the 174.Cm uunlnk 175keyword. 176.El 177.Pp 178Other combinations of keywords may be placed by using 179the octets assigned; however, these are the most notable. 180.Pp 181Unless the 182.Fl H , 183.Fl L , 184or 185.Fl h 186options are given, 187.Nm 188on a symbolic link always succeeds and has no effect. 189The 190.Fl H , 191.Fl L 192and 193.Fl P 194options are ignored unless the 195.Fl R 196option is specified. 197In addition, these options override each other and the 198command's actions are determined by the last one specified. 199.Pp 200You can use 201.Dq Li "ls -lo" 202to see the flags of existing files. 203.Pp 204Note that the ability to change certain flags is dependent 205on the current kernel 206.Va securelevel 207setting. 208See 209.Xr security 7 210for more information on this setting. 211.Sh SWAPCACHE FLAGS 212The 213.Cm cache 214bit may be set to enable 215.Xr swapcache 8 216data caching. 217The superuser flag, 218.Cm noscache 219may be used to disable 220.Xr swapcache 8 221data caching and overrides the user flag. 222.Pp 223The flag is recursive but does not cross mount points. 224Setting it on a top-level directories or mount point will 225automatically apply the flag to the entire subtree or until 226a mount point is hit. 227You may have to refresh the namecache with a dummy 228.Xr find 1 229command after changing the flag in a top level directory. 230You do not have to recursive set the flag with 231.Nm 232.Fl R 233and, in fact, we do not recommend it under any circumstances. 234Filesystems which do not support flags generally have a 235.Cm cache 236mount option to enable swapcache operation on the mount. 237.Pp 238If you intend to use swapcache data the 239.Cm vm.swapcache.use_chflags 240sysctl determines whether the 241.Nm 242flags are used or not. 243If turned off and 244.Cm vm.swapcache.data_enable 245is turned on, data caching is turned on globally and the 246file flags are ignored. 247If 248.Cm use_chflags 249is turned on along with 250.Cm data_enable 251then only subtrees marked cacheable will be swapcached. 252.Pp 253You would typically want to enable the cache on 254.Pa /usr , /home , 255and 256.Pa /bin 257and disable it for 258.Pa /usr/obj . 259Alternatively if you want to cache 260NFS mounts (where 261.Nm 262doesn't work), you can set the flag on 263some parent directory, possibly even the root 264.Pq Pa / 265itself, 266and then selectively disable it in places where you don't want it. 267.Pp 268This only applies to data caching. 269Meta-data caching is universal when enabled. 270.Sh EXIT STATUS 271.Ex -std 272.Sh SEE ALSO 273.Xr ls 1 , 274.Xr chflags 2 , 275.Xr stat 2 , 276.Xr fts 3 , 277.Xr security 7 , 278.Xr symlink 7 , 279.Xr swapcache 8 280.Sh HISTORY 281The 282.Nm 283command first appeared in 284.Bx 4.4 . 285.Sh BUGS 286Only a limited number of utilities are 287.Nm 288aware. 289Some of these tools include 290.Xr ls 1 , 291.Xr cp 1 , 292.Xr find 1 , 293.Xr install 1 , 294.Xr dump 8 , 295and 296.Xr restore 8 . 297In particular a tool which is not currently 298.Nm 299aware is the 300.Xr pax 1 301utility. 302