Posts Tagged mac

Apples file permissions and extended attributes and ACLs

Posted by on Saturday, 26 September, 2009

Whilst i realize this is not ‘linux’ is is unix based and has a similar permissions and command line.

I recently upgraded my OS X laptop to Snow leopard. Being the good sysadmin I am i made sure i used Time Machine to backup all my files and data to an external drive. I used the chance to do a fresh install also, and the upgrade went fine.

I then restored from my backup. I noticed immediately that I couldn’t write to some files and was unable to do some things without entering the root password. Now I had changed the username so i assumed naturally that they would be perhaps owned by my own username and somehow timemachine hadnt changed it.

This was not the case, the permissions seemed fine, they could be all drwxrwxrwx and owned by me i still could not write to them. I did notice the symbol on the end which was an @ symbol.

drwxr-xr-x@   5 wishes  staff         170 18 Jul 22:15 wordpress

Interesting! After much googling i found this is extended attributes symbol, and to view those you can use

ls -l@

drwxr-xr-x@ 146 wishes  staff  4964 28 Aug 21:38 Cheerleading      50      50

After a bit of googling i figured out i can remove this using the command

sudo xattr -d “” filename

So i wrote a quick shell script that stripped both the “” and “” off since none of these files were in time machine any more. I wasn’t sure at that time if this was why i was unable to remove it, as it turns out it wasn’t.

As it turns out by removing the extended attributes i discovered the @ had now turned into a +

-rw-r–r–+   1 wishes  staff       56743 16 Sep 07:03 Recipes.pdf

Again, i set off to google this one. I found this excellent page here which explains all the ACLs. By doing the following i can list all the ACLs

ls -le@O

drwxrwxrwx+   5 wishes  staff  –        170 28 Aug 21:41 Raw Photos
0: group:everyone deny add_file,delete,add_subdirectory,delete_child,writeattr,writeextattr,chown

So now i knew that it was ACLs i was able to remove those with the following

chmod -a# 0 *

Bingo! now i can access all my files happily! Hopefully this saves somebody else the frustration i went through trying to figure it out 🙂