Unprotecting files on Mac OSX copied write-protected from Windows

Today a colleague copied a Together project from his Windows machine to my USB stick, from which I copied the files to my disk. The files were write protected on the Windows machine since the project was managed by Synergy. When I tried to remove write protection from these files I realized that the files were not read-only by standard Unix file attributes and I could not use chmod to write-enable the files. When opening the properties dialog on those files one could see that the flag “Geschützt” (Protected) is set. Since the project consists of some hundred files using the dialog to remove this flag is no option.

After some searching I found this article which explains that OS X has some additional flags that supersede the standard UNIX permissions. These additional flags can be listed with ls by adding the -O option:

ls -AlO
total 152
-rw-r--r--@  1 thoms  thoms  hidden  6148 17 Mai 17:56 .DS_Store
-rwxrwxrwx   1 thoms  thoms  -        312  7 Mai  2009 .checkstyle
-rwxrwxrwx   1 thoms  thoms  -        234  5 Jun  2009 .designRoot
-rwxrwxrwx   1 thoms  thoms  -      48559  6 Mai  2009 .pmd
-rwxrwxrwx   1 thoms  thoms  -        922 21 Okt  2009 .project
drwxrwxrwx   6 thoms  thoms  uchg     204 17 Mai 17:52 Dokumente
drwxrwxrwx  11 thoms  thoms  uchg     374 17 Mai 17:52 Model Folder
-rwxrwxrwx   1 thoms  thoms  uchg      71  7 Mai 10:36 _ccmwaid.inf
-rwxrwxrwx   1 thoms  thoms  uchg    1583 23 Jul  2008 grafiken.tpl

The flags can be read and manipulated with the chflags command. For unsetting the “user immutability flag” on a complete directory execute

chflags -R nouchg *


One thought on “Unprotecting files on Mac OSX copied write-protected from Windows

  1. Hi Karsten,

    nice, didn’t know yet, but you’ve got a typo in the ls:
    Must be a capital O to list the file flags. See in manpage:

    -O Include the file flags in a long (-l) output.

    -o List in long format, but omit the group id.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s