chflags

change file flags

chflags [-fhv] [-R [-H | -L | -P]] flags file

Changes the archived, opaque, nodump, sappend, uappend, simmutable, uimmutable and hidden flags.

-f force, forge-ahead, i.e do not display a diagnostic message if chflags could not modify the flags for file, nor modify the exit status to reflect such failures.
-v verbose, showing filenames as the flags are modified. Specify more than once, old and new flags are output in numeric notation.
-R recurse, Change the flags for the file hierarchies rooted in the files instead of just the files themselves.
Links
-h symbolic link: change the file flags of the link itself not than the file to which it points.
-R -H symbolic links on the command line are followed. (Symbolic links encountered in the tree traversal are not followed.)
-R -L all symbolic links are followed.
-R -P Prevent symbolic links from being followed. default.

To set the flags specify a numeric or a comma separated list of keywords.

arch
archived
002000000
archived (super-user only)
opaque
000000010
. [Directory is opaque when viewed through a union mount]
nodump
000000001
sappnd
sappend
010000000
system append-only (super-user only)
uappnd
uappend
000000004
user append-only
schg
schange
simmutable
004000000
system immutable (super-user only)
makes the file/folder Locked/Protected and is equivalent to locking the file in Finder's Show Info box.
uchg
uchange
uimmutable
000000002
user immutable
Prevents even root from updating owner via chown
hidden
001000000
hidden [Hide item from GUI]


The sappnd and schg flags may only be unset when the system is in single-user mode. As discussed in chflags(2), as of Darwin Mountain Lion 11/5/12

The no prefix causes the flag to be cleared. For example:

nouchg clear the user immutable flag
dump clear the nodump flag

Example:
chflags -v -v nouchg DSCN0608.JPG
DSCN0608.JPG: 02 -> 00

Unless -H or -L are given, chflags on a symbolic link always succeeds and has no effect.
The -H, -L and -P options are ignored unless -R is specified, override each other and the actions are determined by the last one specified.

Use ls -lO to see the flags .
-rwxrwxrwx 1 dgerman staff - 7888853 Feb 17 09:21 DSCN0672.JPG*
-rwxrwxrwx 1 dgerman staff uchg 8209104 Feb 17 09:21 DSCN0673.JPG*
-rwxrwxrwx@ 1 dgerman staff - 3575147 Mar 11 17:59 DSCN0675.JPG*

Exit status

1: invalid flags or No such file or directory

See

ls, chflags, stat, fts, symlink

exceptions

Only a limited number of utilities are chflags aware. These include ls, cp, find, install, dump and restore. In particular pax( a backup utility) is NOT aware .