Force Empty Trash in Mac OS X When File is Locked or In Use

Mac OS X can sometimes throw permissions errors when trying to delete files or empty the Trash. The most common variations of the errors are usually “Operation cannot be completed because the item “File” is in use” or “because the file is locked”, sometimes you can get around this by just quitting open applications or rebooting the Mac, but if you don’t want to do either you can also forcibly remove files through the command line. We will cover two different approaches to this, the first changes a files flags to attempt to unlock the file in question, and the second is a no-nonsense force delete.
First: Try quitting all apps to release the file lock or permissions, then attempt to Secure Empty Trash by holding down the Command key and right-clicking the Trash icon. If that doesn’t work, proceed with the methods outlined below.
Change Permissions To Forcibly Empty Trash
The first approach uses the chflags command to change the flags of all files in the Trash
Launch Terminal found in /Applications/Utilities/ and then proceed:
cd ~/.Trash
chflags -R nouchg *
Now you can try emptying the Trash as usual through the Dock, or go the rm route mentioned below.
Advanced: Forcibly Emptying the Trash via Command Line
This is a last resort and intended only for advanced users. Make sure the syntax is correct with this, the “sudo rm -rf” command will erase anything without warning. If you don’t know what you’re doing you could easily delete crucial system or personal files. Have backups ready or don’t bother with this method, proceed at your own risk.
First change the directory to Trash:
cd ~/.Trash
Confirm you are in the proper directory and the only files you see are the ones you want to forcibly remove by using ls:
ls
Now try to delete the specific file:
rm filename.jpg
If that still doesn’t work you can try the ultimate delete approach using sudo and -rf *. This is intentionally not spelled out easily to try and prevent any novice users from accidentally deleting something significant.
Using sudo requires the administrator password but combined with rm it will absolutely forcibly remove any file regardless of whats going on with it.

I usually just use TrashIt! It’s free.
tried trash it, but not working!
Used it for a stubborn locked file and worked perfectly.
I just always right click the trash and hold command key to secure empty. Works every time to overwrite error.
Good job Trevor, even the guys at the genius bar here in Naples didnt know that trick:-) worked perfectly!
just press Command Option Shift and Delete and it will empty the trash even if the file is owned by another user
Good man! After trying Terminal and all the suggestions on another site trying to delete old Time machine Back Ups Command Option Shift and Delete the trash worked.
Thanks Anonymous
I have tried everything as well … And this was the ONE thing that completely erased my Trash Box! Thank YOU!
I have tried EVERY tip before and this is the only thing that would completely empty my trash. Thank you!!!
Thank you!! Thank you!! Thank you!! Muchly appreciated.
If it complains about the file being in use you can also “lsof | grep filename” and see what program is using it so you can close it. Worked every time for me.
In most cases, I just try again, and it deletes without incident.
To Trevor and Anonymous… and this web site/comments… Thank You! I have been working for two days trying to delete locked files from the Trash on my iMac running OS 10.8. Nothing worked until I came across this list of comments. I tried everything and I mean everything, but nothing worked. I will add that after I was able to delete the locked files holding down the Command Key. I then went back and added the Admin and myself to the permissions list and changed everyone’s permission listed to Read & Write. Then I held down the Shift, Option & Command key right clicked the Trash and Bam… they were all deleted. Thank You Again!
excellent thanks – so frustrating trying to get rid of stuff!
you only need:
cd .Trash/
rm -rf *
check your current directory and be sure to be in ~/.Trash, if you run the command rm -rf * in a wrong place and wrong user, prepare do reinstall your system.
Perfect. So simple. Dangerous if you don’t change directory to Trash, but if you don’t know to do that, you shouldn’t be messing about in Terminal in the first place.
I tried everything!! Then paydirt!! Just went to disk utility and repair permissions. Viola!!
i was working on this last night but fall asleep not finishing the job. so i woke up the next morning and the first thing i did, terminal x…rm -rf *. woooooops wrong dir, here i am trying to fix it…
try using this command,
rm -rf ~/.Trash/*
Numerous utilities will do this all for you with the click of a button. Onyx being one of them, MainMenu another.
DUDE!! Thank you for posting this. Very clean way to tidy up the stuck on trash! You rock.
I have tried using the command suggested but my problem is that every time I start a secure empty trash it stops after a few seconds and doesn’t delete any files,
I tried every method I could find and couldn’t get rid of a locked file deleted from Time Machine. Then I ran routine cleaning with OnyX and it deleted it with no fanfare.
Thanks, it worked out perfectly!
If you don’t want to Terminal bash it, you can try right clicking on the file while it’s in the trash, then press cmd and choose Empty Trash. This works 7/10ish is the file is persistent with just a regular emptying.
Failing that, I use the app Find Any File. Copy the file’s name that needs deleting, and paste it into Find Any File. Once found, right click on the file and choose “Delete Immediately”. Works a charm.
Change Permissions To Forcibly Empty Trash
Thank you it worked for me.
how do you changed permissions to forcibly empty trash?