1.\" $OpenBSD: chflags.1,v 1.19 2019/09/02 21:18:41 deraadt 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: September 2 2019 $ 37.Dt CHFLAGS 1 38.Os 39.Sh NAME 40.Nm chflags 41.Nd change file flags 42.Sh SYNOPSIS 43.Nm chflags 44.Op Fl h 45.Oo 46.Fl R 47.Op Fl H | L | 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. 58The 59.Ar flags 60of a file dictate special restrictions beyond those enforced by its 61mode/permissions. 62Only the superuser can change the user flags on block and 63character devices. 64.Pp 65You can use 66.Sy ls Fl lo 67to see the flags of existing files. 68.Pp 69The options are as follows: 70.Bl -tag -width Ds 71.It Fl H 72If the 73.Fl R 74option is also specified, symbolic links on the command line are followed. 75Symbolic links encountered in the tree traversal are not followed. 76.It Fl h 77Treat symbolic links like other files: modify links instead of 78following them. 79The 80.Fl h 81and 82.Fl R 83options are mutually exclusive. 84.It Fl L 85If the 86.Fl R 87option is also specified, all symbolic links are followed. 88.It Fl P 89If the 90.Fl R 91option is also specified, no symbolic links are followed. 92.It Fl R 93Recurse. 94Where 95.Ar file 96is a directory, 97change the flags of the directory and all the files and directories 98in the file hierarchy below it. 99.El 100.Pp 101Flags are a comma separated list of keywords. 102The following keywords are currently defined: 103.Pp 104.Bl -tag -width "nodump" -compact -offset indent 105.It Cm arch 106set the archived flag (superuser only) 107.It Cm nodump 108set the nodump flag (owner or superuser only) 109.It Cm sappnd 110set the system append-only flag (superuser only) 111.It Cm schg 112set the system immutable flag (superuser only) 113.It Cm uappnd 114set the user append-only flag (owner or superuser only) 115.It Cm uchg 116set the user immutable flag (owner or superuser only) 117.El 118.Pp 119The 120.Cm arch 121flag is for compatibility only, 122and currently has no effect. 123.Pp 124A file with the 125.Cm nodump 126flag set will by default only be backed up by 127.Xr dump 8 128during full backups. 129The 130.Fl h 131option of 132.Xr dump 8 133can be used to alter this. 134.Pp 135An immutable file may not be changed, moved, or deleted. 136An append-only file is immutable except that data may be appended to it. 137.Pp 138The 139superuser-settable 140.Cm sappnd 141and 142.Cm schg 143flags can be set at any time, but may only be cleared when the system is 144running at security level 0 or \-1 145(insecure or permanently insecure mode, respectively). 146For more information on setting the system security level, 147see 148.Xr securelevel 7 . 149.Pp 150Putting the letters 151.Cm no 152before a flag name causes the flag to be turned off. 153For example: 154.Pp 155.Bl -tag -width "nouchg" -compact -offset indent 156.It Cm nouchg 157the immutable bit should be cleared 158.El 159.Pp 160The 161.Fl H , 162.Fl L , 163and 164.Fl P 165options are ignored unless the 166.Fl R 167option is specified. 168In addition, these options override each other and the 169command's actions are determined by the last one specified. 170.Sh EXIT STATUS 171.Ex -std chflags 172.Sh SEE ALSO 173.Xr ls 1 , 174.Xr chflags 2 , 175.Xr stat 2 , 176.Xr fts_open 3 , 177.Xr securelevel 7 , 178.Xr symlink 7 , 179.Xr dump 8 180.Sh HISTORY 181The 182.Nm 183command first appeared in 184.Bx 4.4 . 185