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.\" 4. 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 April 8, 2013 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 fhv 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. 70(Symbolic links encountered in the tree 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 for the file hierarchies rooted 87in the files instead of just the files themselves. 88.It Fl v 89Cause 90.Nm 91to be verbose, showing filenames as the flags are modified. 92If the 93.Fl v 94option is specified more than once, the old and new flags of the file 95will also be printed, in octal notation. 96.El 97.Pp 98The flags are specified as an octal number or a comma separated list 99of keywords. 100The following keywords are currently defined: 101.Bl -tag -offset indent -width ".Cm opaque" 102.It Cm arch , archived 103set the archived flag (super-user only) 104.It Cm nodump 105set the nodump flag (owner or super-user only) 106.It Cm opaque 107set the opaque flag (owner or super-user only) 108.It Cm sappnd , sappend 109set the system append-only flag (super-user only) 110.It Cm schg , schange , simmutable 111set the system immutable flag (super-user only) 112.It Cm snapshot 113set the snapshot flag (filesystems do not allow changing this flag) 114.It Cm sunlnk , sunlink 115set the system undeletable flag (super-user only) 116.It Cm uappnd , uappend 117set the user append-only flag (owner or super-user only) 118.It Cm uarch , uarchive 119set the archive flag (owner or super-user only) 120.It Cm uchg , uchange , uimmutable 121set the user immutable flag (owner or super-user only) 122.It Cm uhidden , hidden 123set the hidden file attribute (owner or super-user only) 124.It Cm uoffline , offline 125set the offline file attribute (owner or super-user only) 126.It Cm urdonly , rdonly , readonly 127set the DOS, Windows and CIFS readonly flag (owner or super-user only) 128.It Cm usparse , sparse 129set the sparse file attribute (owner or super-user only) 130.It Cm usystem , system 131set the DOS, Windows and CIFS system flag (owner or super-user only) 132.It Cm ureparse , reparse 133set the Windows reparse point file attribute (owner or super-user only) 134.It Cm uunlnk , uunlink 135set the user undeletable flag (owner or super-user only) 136.El 137.Pp 138Putting the letters 139.Dq Ar no 140before or removing the letters 141.Dq Ar no 142from a keyword causes the flag to be cleared. 143For example: 144.Pp 145.Bl -tag -offset indent -width "nouchg" -compact 146.It Cm nouchg 147clear the user immutable flag (owner or super-user only) 148.It Cm dump 149clear the nodump flag (owner or super-user only) 150.El 151.Pp 152A few of the octal values include: 153.Bl -tag -offset indent -width ".Li 10" 154.It Li 0 155Clear all file flags. 156.It Li 1 157Translates to the 158.Cm nodump 159keyword. 160.It Li 2 161Translates to the 162.Cm uchg 163keyword. 164.It Li 3 165Translates to the 166.Cm uchg , nodump 167keywords. 168.It Li 4 169Translates to the 170.Cm uappnd 171keyword. 172.It Li 10 173Translates to the 174.Cm opaque 175keyword. 176.It Li 20 177translates to the 178.Cm uunlnk 179keyword. 180.El 181.Pp 182Other combinations of keywords may be placed by using 183the octets assigned; however, these are the most notable. 184.Pp 185Unless the 186.Fl H , 187.Fl L , 188or 189.Fl h 190options are given, 191.Nm 192on a symbolic link always succeeds and has no effect. 193The 194.Fl H , 195.Fl L 196and 197.Fl P 198options are ignored unless the 199.Fl R 200option is specified. 201In addition, these options override each other and the 202command's actions are determined by the last one specified. 203.Pp 204You can use "ls -lo" to see the flags of existing files. 205.Pp 206Note that the ability to change certain flags is dependent 207on the current kernel 208.Va securelevel 209setting. 210See 211.Xr security 7 212for more information on this setting. 213.Sh EXIT STATUS 214.Ex -std 215.Sh SEE ALSO 216.Xr ls 1 , 217.Xr chflags 2 , 218.Xr stat 2 , 219.Xr fts 3 , 220.Xr security 7 , 221.Xr symlink 7 222.Sh HISTORY 223The 224.Nm 225command first appeared in 226.Bx 4.4 . 227.Sh BUGS 228Only a limited number of utilities are 229.Nm 230aware. 231Some of these tools include 232.Xr ls 1 , 233.Xr cp 1 , 234.Xr find 1 , 235.Xr install 1 , 236.Xr dump 8 , 237and 238.Xr restore 8 . 239In particular a tool which is not currently 240.Nm 241aware is the 242.Xr pax 1 243utility. 244