How to fix a file that’s read-only despite showing correct permissions

permissionsnow leopard

A file copied from a NTFS share has become read-only, other files in the same folder are OK.

Finder's Info says in the Sharing & Permissions:

You can only read 
Name        Privilege 
myname (Me) Read & Write 
admin       Read only 
everyone    Read only

ls -l@

total 142040
-rwxr-xr-x  1 myname admin  5388424 Sep 17  1998 Bad File
-rwxr-xr-x  1 myname admin  3534780 Feb  3 21:36 Good File

How to undo? chown/chmod didn't do anything…

Best Answer

Try ls -lO to see if any file flags are set. If it's locked (uchg flag), you can unlock it in either the Finder's Get Info window, or with chflags nouchg "Bad File". If some other flag is set, use chflags no<whatever> "Bad File" to clear it.

EDIT: The -O flag to la adds another column between the group and size of the files, listing file flags (if any). Note that flags are entirely separate from extended attributes (what -@ displays). Here's an example:

$ touch "Normal File" "Locked File" "Invisible, Append-only File"
$ chflags uchg "Locked File"
$ chflags uappnd,hidden "Invisible, Append-only File"
$ ls -l
total 0
-rw-r--r--@ 1 gordon  wheel  0 Feb  4 07:24 Invisible, Append-only File
-rw-r--r--  1 gordon  wheel  0 Feb  4 07:24 Locked File
-rw-r--r--  1 gordon  wheel  0 Feb  4 07:24 Normal File
$ ls -lO
total 0
-rw-r--r--@ 1 gordon  wheel  uappnd,hidden 0 Feb  4 07:24 Invisible, Append-only File
-rw-r--r--  1 gordon  wheel  uchg          0 Feb  4 07:24 Locked File
-rw-r--r--  1 gordon  wheel  -             0 Feb  4 07:24 Normal File

The uchg flag is what gets set if you check the "Locked" box in a file's Get Info window. BTW, the "hidden" flag only affects the Finder -- the only way to hide files from the command line is to put a . at the front of the filename.