The only problem is that I want to understand who is using this file and why it is still using it when there is no apparent task running.
You try to empty your trash, you get an error
"The operation can’t be completed because the item XYZ is in use."
You check with Command-Tab and there s nothing running except Finder. Who the hell is using this file?
Here comes the dreaded Terminal. Don't be scared it is just another way to control your computer, if you are careful there is no problem.
Careful this one is no return.
This should do it. If it doesn't work it is generally caused by Sharing and Permissions on the file
Change Sharing and Permissions on a file
Sometimes, when copying files from external drives, removable USB sticks etc, files are copied with strange permissions, often they are Read-Only or you are not the owner.
To see who owns that file and what permission you have, select the file in the trash or finder
Command-I or Right Click > Get Info
At the bottom in the Sharing & Permissions you see who owns the file and which rights you have
To delete a file you should have Read-Write privileges
You check with Command-Tab and there s nothing running except Finder. Who the hell is using this file?
Here comes the dreaded Terminal. Don't be scared it is just another way to control your computer, if you are careful there is no problem.
- Open Terminal (you can type "Terminal" in SpotLight (Top right magnifier)
- Type
lsof | grep Don't type Enter yet
lsof is a command that lists open files
- Try to empty the trash again and copy the filename (⌘-C) from the error message
- Return to Terminal and paste the name of the file using ⌘-V (Command-V)
- If the filename contains spaces and special characters enclose in quotes as below
lsof | grep "file that cant be deleted.png" <enter>
- You should see something like this:
MyMac:~ guest $ lsof | grep "Screen shot 12.30.28 PM.png"
Mail 63367 guest ... /Users/guest/.Trash/Screen shot 12.30.28 PM.png
See? Mail is using the file, that's why I can't delete it. In your case it could be any other application. The name of the application is first on the line.
Now that you know the app that keeps your file opened you can do one of three things:
- You need the file and will have to put it back where it belongs
- You can Close the app using it.
- You don't need the file and want to delete it anyway! Force delete.
Force Delete
Careful this one is no return.
- Command Right click on your trash
- Select Secure Empty Trash
This should do it. If it doesn't work it is generally caused by Sharing and Permissions on the file
Change Sharing and Permissions on a file
Sometimes, when copying files from external drives, removable USB sticks etc, files are copied with strange permissions, often they are Read-Only or you are not the owner.
To see who owns that file and what permission you have, select the file in the trash or finder
Command-I or Right Click > Get Info
At the bottom in the Sharing & Permissions you see who owns the file and which rights you have
To delete a file you should have Read-Write privileges
- Unlock the file by clicking on the small closed padlock and entering your password
- Change the file privilege to Read-Write if Read-Only
- If your name is not there add your user name by clicking on + and a selecting your name, then select read write
- Now you should be able to delete the file
Other method (Apple recommended but long)
Using DiskAid and Repair permissions you can fix most of permission issues. This should be done once a month if you move a lot of files to and from external USB drives.
Check the Apple support document: Troubleshooting permissions issues in Mac OS X
Mad*
PS: When you run command in Terminal Control-C will terminate the command and return to the prompt. Don't forget to close Terminal after using it!





