I have just saved some data from a crashed PC to my external HD, which is a HFS+ Volume using Ubuntu live (regular copy no dd).
Now I am lost: I don't have any privileges in the Folder i copied on my Macbook. I tried changing it using chmod and chown, both as regular user and as root, but I always get a "operation not permitted".The owner for all those files is "999".

4 Answers
4

press CMD-I on the top directory where are your files in the external HDD

click on the lock symbol (right bottom corner)

enter your password

and adjust the 1st line at the permission section (Me) for "Read & Write", and from the cogwheel select "Apply to enclosed items..."

The above should repair permissions - but - probably will not help (as you already told)

Part2:

If the part1 not helped, probably (and only maybe!) you have an broken ACL list. (because files are copied at another OS). OS X HFS has not only usual chmod modes, but maintain ACL (access control list) too.

Try this in the Terminal.app - DON'T copy&paste all at once, enter the commands one by one...

cd /Volumes/MOUNT_POINT/directory/with/the/backed/up/files
# where MOUNT_POINT is the drive name as appears in the Finder.
pwd
# DOUBLE CHECK the pwd
# if you do the next on the wrong place - you can corrupt your system
# YOURE WARNED!!!
#this will remove all ACL informations recursively from all files in your current dir
sudo chmod -RN ./*
#this will change recursively the ownership of the files -> to you.
sudo chown -R $(whoami) ./* #change ownership of files to you
cd # go home

now you can quit Terminal.app and check access to files via Finder and you should repeat the first part - changing permissions via Finder's -> CMD-I ...

This is all very interesting (and new to me). My disk (HFS+ with shared Linux and OS X use) has a folder in a stage where I cannot change the "everyone" access props from "no rights" to "r&w" as I'd like. The UI implies it can be done (yes, I opened the lock). But nothing happens! Strange.
–
akauppiJun 29 '13 at 14:32

As Karmatic has said, it may likely be an issue with ACLs, but I would advise against changing your users UID as that seems like a backward solution and may break things (like the inability to login or access some critical files). You want to fix the files, not break the user UID ;)

If the problems lie with ACLs, or rather ACEs (which are the rulesets for ACL, or better known as access control entries), then you need to repair them. You can list a directory or files ACEs using the ls "e" function.

Run the "ls -le" command from Terminal. You should see output like this:

In the above example, you can see that I am the owner and the group those directories belong to is "staff", which I am a part of. Then you can see that each one has the same ACE, in this case, not everyone can delete the directory. So if we put it all together, there are no ACEs that protect the directories from read or write, but there is no that protects it from deletion, so that you either have to be the owner, or part of that group to delete it. It is also of note that ACEs are ordered lists, in that, the first rule hit is the one that applies, and all the rest get ignored. For example, if you had a rule that allowed write to a file, and then one that prevented write right after it, the file would be writeable.

I had a similar situation when I tried to access system files of a NAS drive through my iMac. As @jm666 already pointed out this happens due to ACLs. When you create a user in Mac he/she gets a unique ID(uid) in the range of 500+. You can find your current uid by running,id on the Terminal.app. However Linux uids starts at 1000(e.g. Ubuntu).

If all the other solutions didn't work you can try to create a new user on your Mac and a group with a id similar to linux user and you should be able to access all the files with read/write permissions.