1.\" $MirOS: src/bin/chmod/chflags.1,v 1.2 2007/05/20 19:20:28 tg Exp $ 2.\" $NetBSD: chflags.1,v 1.17 2003/08/07 11:13:16 agc Exp $ 3.\" $OpenBSD: chflags.1,v 1.5 2004/09/28 22:11:40 jmc Exp $ 4.\" $NetBSD: chflags.1,v 1.4 1995/08/31 22:50:22 jtc Exp $ 5.\" 6.\" Copyright (c) 1989, 1990, 1993, 1994 7.\" The Regents of the University of California. All rights reserved. 8.\" 9.\" This code is derived from software contributed to Berkeley by 10.\" the Institute of Electrical and Electronics Engineers, Inc. 11.\" 12.\" Redistribution and use in source and binary forms, with or without 13.\" modification, are permitted provided that the following conditions 14.\" are met: 15.\" 1. Redistributions of source code must retain the above copyright 16.\" notice, this list of conditions and the following disclaimer. 17.\" 2. Redistributions in binary form must reproduce the above copyright 18.\" notice, this list of conditions and the following disclaimer in the 19.\" documentation and/or other materials provided with the distribution. 20.\" 3. Neither the name of the University nor the names of its contributors 21.\" may be used to endorse or promote products derived from this software 22.\" without specific prior written permission. 23.\" 24.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 25.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 27.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 28.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 30.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34.\" SUCH DAMAGE. 35.\" 36.\" @(#)chflags.1 8.4 (Berkeley) 5/2/95 37.\" 38.Dd May 20, 2007 39.Dt CHFLAGS 1 40.Os 41.Sh NAME 42.Nm chflags 43.Nd change file flags 44.Sh SYNOPSIS 45.Nm chflags 46.Oo 47.Fl R 48.Op Fl H | L | P 49.Oc 50.Op Fl h 51.Ar flags 52.Ar file Op Ar ... 53.Sh DESCRIPTION 54The 55.Nm 56utility modifies the file flags of the listed files 57as specified by the 58.Ar flags 59operand. 60The 61.Ar flags 62of a file dictate special restrictions beyond those enforced by its 63mode/permissions. 64.Pp 65The options are as follows: 66.Bl -tag -width Ds 67.It Fl R 68Recursively descend through any specified directory arguments. 69Change the flags of the file hierarchies rooted 70in the files instead of just the files themselves. 71.It Fl H 72If the 73.Fl R 74option is also specified, symbolic links on the command line are followed. 75(Symbolic links encountered in the tree traversal are not followed.) 76.It Fl L 77If the 78.Fl R 79option is also specified, all symbolic links are followed. 80.It Fl P 81If the 82.Fl R 83option is also specified, no symbolic links are followed. 84.It Fl h 85If the 86.Ar file 87or a file encountered during directory traversal is a symbolic link, 88the file flags of the link itself is changed. 89.El 90.Pp 91Flags are a comma separated list of keywords. 92The following keywords are currently defined: 93.Bd -literal -offset indent 94arch set the archived flag 95opaque set the opaque flag (owner or superuser only) 96nodump set the nodump flag (owner or superuser only) 97sappnd set the system append-only flag (superuser only) 98schg set the system immutable flag (superuser only) 99uappnd set the user append-only flag (owner or superuser only) 100uchg set the user immutable flag (owner or superuser only) 101.Ed 102.Pp 103An immutable file may not be changed, moved, or deleted. 104An append-only file is immutable except that data may be appended to it. 105.Pp 106Putting the letters 107.Dq no 108before a flag name causes the flag to be turned off. 109For example: 110.Pp 111.Dl nouchg the immutable bit should be cleared 112.Pp 113The 114superuser-settable 115.Dq sappnd 116and 117.Dq schg 118flags can be set at any time, but may only be cleared when the system is 119running at security level 0 or \-1 120(insecure or permanently insecure mode, respectively). 121For more information on setting the system security level, 122see 123.Xr securelevel 7 . 124.Pp 125The 126.Fl H , 127.Fl L , 128and 129.Fl P 130options are ignored unless the 131.Fl R 132option is specified. 133In addition, these options override each other and the 134command's actions are determined by the last one specified. 135.Pp 136Only the superuser can change the user flags on block and 137character devices. 138.Pp 139You can use 140.Ic ls -lo 141to see the flags of existing files. 142.Pp 143The 144.Nm 145utility exits 0 on success or >0 if an error occurred. 146.Sh SEE ALSO 147.Xr ls 1 , 148.Xr chflags 2 , 149.Xr lchflags 2 , 150.Xr stat 2 , 151.Xr fts 3 , 152.Xr securelevel 7 , 153.Xr symlink 7 154.Sh HISTORY 155The 156.Nm 157command first appeared in 158.Bx 4.4 . 159The 160.Fl h 161option first appeared in 162.Mx 10 . 163