"The operation can’t be completed because the item is in use" when deleting from Samba mounted drive
Solution 1:
There are actually two messages you're referring to:
"This operation can't be completed because the item is in use"
and
"The operation can’t be completed because you don’t have permission to access some of the items."
If you see the first one - I sometimes get that message too. Quite often this can be resolved by running: sudo lsof | grep <filename>
in Terminal.app - obviously replace <filename>
with the actual name of the file you're trying to delete. I typically get this when trying to empty the trash, but if the trash is not supported on the filesystem you have mounted, you may see it when trying to delete.
What lsof
does is it lists all open files, and shows which process opened each of them. Quite often this will be a quick look process that opened the file and somehow didn't close it (it will do that when you display a list of movie files in Finder - it will then try to show you the first frame of the movie in the preview, and it's using Quick Look to do that).
Usually after running the lsof
the files are closed (that's if lsof
doesn't show anything), or I can just kill the quick look process and then empty the trash.
As for the other message - the best thing to do is to run ls -la <filename>
or ls -lad <directory>
to see the permissions on the file or the folder you're trying to remove. This may give you a better idea where the problem is.