Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

So, I have a folder in my ~./Trash folder, and I can't seem to delete it. It's named __MACOSX, and I've tried everything I can think of to get rid of it. Finder won't start at all because of it (it starts for a bit at login, but then crashes/freezes), the terminal freezes up when trying to remove it (both as me and as sudo), and it even freezes up when auto-completing (tabbing) after typing the first few characters of it. Any suggestions?

Update: doing a normal ls lists it just fine, but an ls -l to try and find out more about it freezes the terminal:

polaris:~ rob$ cd .Trash/
polaris:.Trash rob$ ls
__MACOSX
polaris:.Trash rob$ ls -l
^C^C

(Pressing ^C doesn't do anything)

Another update: Onyx's trash utility freezes while deleting trash or secure deleting trash, SuperEmptyTrash crashes,

share|improve this question
    
Did you try to check your disk for problems? –  Matteo Mar 25 '12 at 5:47
    
@Matteo do you mean verify/repair disk in Disk Utility.app? –  penguinrob Mar 25 '12 at 5:49
    
Yes, and also permissions. –  Matteo Mar 25 '12 at 5:54
    
Did both of those and they came back fine. It said the volume appears to be OK, and the only changed permission was the apache documentroot that I changed, which I doubt would be the issue –  penguinrob Mar 25 '12 at 6:04
add comment

4 Answers 4

up vote 1 down vote accepted

I can think of a couple of things.

First, try deleting everything in your .Trash folder with sudo privileges:

sudo rm -rf ~/.Trash/*

If that fails, then try resetting the PRAM on your Mac. Sometimes doing so can surprisingly fix odd errors.

Finally, make sure that the permissions on your .Trash folder are correct

ls -ale ~/.Trash/

The permission for the folder should be like the following:

drwx------ 24 username staff 816 Mar 24 22:06 .

drwxr-xr-x+ 34 username staff 1156 Mar 24 09:51 ..

share|improve this answer
    
Of course, if ls -l freezes up Terminal, then checking for permissions will probably do the same thing. It's worth a shot, though. –  sudo rm -rf Mar 25 '12 at 5:54
    
yep, it still freezes it up. –  penguinrob Mar 25 '12 at 6:01
    
Have you tried deleting the trash folder as I mentioned? If you have, then try repairing your home folder permissions: osxdaily.com/2011/11/15/… Please note this permission repair is different from your standard Disk Utility repair. You actually need to reboot your Lion machine. –  sudo rm -rf Mar 25 '12 at 6:03
    
Yes, I have. I still have that command open in a Terminal tab from an hour ago to see if it would just take a while, but it's still frozen. –  penguinrob Mar 25 '12 at 6:05
    
Before you restart, can you try something for me? I have a hunch. sudo fs_usage -f filesys | grep ~/.Trash That's going to show when anything tries to access your trash folder. I wonder if something has a read lock on it and it's not letting it go. –  sudo rm -rf Mar 25 '12 at 6:06
show 5 more comments

First I suggested "sudo rm -rf __MACOSX" - that freezes the terminal.

Hmm. I only have a .Trashes in my ~, are you in 10.7?

Anyway - "ls -lA" shows the trailing permission character is t, so "only file owners can link or unlink files in the specified directory". In this case you want to unlink (delete). The owner of this directory is root, so you need to be root.

By default you can't "su" in Lion. You can enable the root account using Directory Services, in /System/Library/CoreServices. Authenticate then choose "Enable Root User" in the edit menu.

Once that is done a plain "su" followed by the password makes you actually "root" not just another user doing things with root's permissions. The prompt will change to something very much like sh-3.2# instead of the usual, and whoami will reply "root".

Then you should be able to kill that file!

share|improve this answer
    
Yup, I've tried that, just freezes the terminal. –  penguinrob Mar 25 '12 at 5:44
    
I think I found the way after some digging... –  Adam Eberbach Mar 25 '12 at 5:49
    
I assume running su is the same as sudo -i, since I still get root for whoami. It still freezes up the terminal when trying to delete it. –  penguinrob Mar 25 '12 at 6:03
1  
Try "sudo chflags nouchg __MACOSX" - and then try again? I would suggest "sudo chflags noschg __MACOSX" also but I think you have to boot to single-user mode for that - if you want to try it, reboot and hold command-S as you boot. –  Adam Eberbach Mar 25 '12 at 6:14
    
How did you go, penguinrob? Looks like I scored a drive-by downvote here, I assume it wasn't you. –  Adam Eberbach Mar 25 '12 at 23:47
show 2 more comments

I moved the folder to /tmp and restarted my machine. I believe /tmp isn't retained across reboots so I let the system take care of the issue.

share|improve this answer
    
And did it work? –  patrix May 18 '12 at 15:52
add comment

I tried all the suggestions above except the last one because I didn't want the machine to fail to boot up in case it got hung trying to erase an un-erasable file. But the following worked:

  1. Moved __MACOSX out of trash by dragging it into an empty folder.
  2. From Finder changed permissions so that owner, group, everyone could read/write/execute.
  3. Opened terminal and issued sudo -r -f __MACOSX

I was surprised that the above worked but it did!

share|improve this answer
1  
I assume you used Finder to move the folder out of the trash, but that wouldn't work for me because Finder wouldn't even start at all. The Terminal hung whenever I tried to do anything, but thanks for telling what worked for you! –  penguinrob Sep 20 '12 at 22:05
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.