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