Change a file or folder's flags.
Syntax chflags [-R [-H | -L | -P]] flags file ... Options -R Recurse: Change the file flags of file hierarchies rooted in the files instead of just the files themselves. -R -H Follow symbolic links on the command line (by default Symbolic links within the tree are not followed.) -R -L All symbolic links are followed. -R -P No symbolic links are followed. (default)
The flags are specified as an octal number or a comma separated list of keywords.
hidden set the hidden flag [Hide item from GUI]
Keywords and keyword aliases - Owner or Super-user only:
opaque set the opaque flag nodump set the nodump flag uappnd, uappend set the user append-only flag uchg, uchange, uimmutable set the user immutable flag uunlnk, uunlink set the user undeletable flag
Keywords and keyword aliases - Super-user only:
arch, archived set the archived flag sappnd, sappend set the system append-only flag schg, schange, simmutable set the system immutable flag sunlnk, sunlink set the system undeletable flag
The immutable flag makes the file/folder Locked/Protected and is equivalent to locking the file in Finder's Show Info box.
Putting the letters no before an option causes the flag to be turned off.
For example: uchg Means the file cannot be changed nouchg Means the file can be changed (immutable bit cleared) hidden Will set the hidden flag nohidden Will remove the hidden flag
Symbolic links do not have flags, so unless the -H or -L option is set,
chflags on a symbolic link always succeeds and has no effect. The -H, -L
and -P options are ignored unless the -R option is specified. In addition, these options override each other and the command's actions are
determined by the last one specified.
The sappnd and schg flags can only be unset
when the system is in single-user mode. chflags(2).
Use ls -lo to see the flags of existing files.
The return status is zero if the mode is successfully changed,and >0 if an error occurs.
Lock the folder "finance" against changes:
$ chflags uchg finance
Unlock the folder named "finance" and allow changes to all the contents:
$ chflags -R nouchg finance
Make the folder ~/Library visible (this was the default setting prior to OS X Lion )
$ chflags nohidden ~/Library
(An alternative method is to use the 'Go' drop down menu in Finder and hold down the option key.)
Hide the folder ~/Library from finder:
$ chflags hidden ~/Library
Make the file MyLogs.txt append-only
$ chflags uappnd MyLogs.txt
Unlock your Documents directory and everything in it
$ chflags -R nouchg ~/Documents
“Fifteen referees. I want fifteen referees to be at this fight because there ain't no one man who can keep up with the pace I'm gonna set except me. There's not a man alive who can whup me. I'm too fast. I'm too smart. I'm too pretty. I should be a postage stamp. That's the only way I'll ever get licked”
~ Muhammad Ali
chflags man page - Apple.com
ht1526 - Empty the (locked) trash with chflags
ln - Make links between files (hard links, symbolic links)
ls - List information about file(s)
setfile - Set attributes of HFS+ files