Fun With My Mac and chflags

Tonight I worked some more with my photo collection on my Mac.  I transferred the files from a Windows box.  After the transfer I ran into an interesting problem; I couldn't remove some of the files from my Mac using the "rm" command.  Rm refused with a message of something like the following:

$ rm file-a
override rw-r--r--  kindred/staff uchg for file-a? y
rm: file-a: Operation not permitted
$

Had I been using the GUI Finder, it would have told me the file was locked.  I wasn't using the Finder though, so I found the following article with Google...  From there I was able to "man chflags" to see what I needed to do to remove the file.

$ chflags nouchg file-a
$ rm file-a

"ls -l" doesn't show the flags.  To see them you need to use "ls -lO".

$ ls -lO
total 0
-rw-r--r--  1 kindred  staff  uchg 0 Jun 29 23:21 file-b
-rw-r--r--  1 kindred  staff  -    0 Jun 29 23:21 file-c

Above we see that file-b has the uchg flag set while file-c does not.

Like I said, had I been using Finder it would have asked me if I wanted to remove the locked file and let me do so.  Finder also shows a little lock symbol with each locked file.

© Donald Kindred 2017

Made on a Mac