Most of the time, taking out the Trash is easy: simply Control-click the Trash icon in your Mac’s Dock and select ‘Empty Trash.’
But from time to time, you may run into problems.
In this article, I’ll show you how to delete any file, folder or application, even if the item in question is locked, currently in use, or you lack the permissions required to send that item to the Trash.
File in use? Track down the app that’s responsible
If you try to empty the Trash and receive a warning that one (or more) files are currently in use, then you’ll need to close all the applications that are using that file.
This may sound straightforward, but if you’re unsure what these applications are, then you’ll need to do some digging:
- Launch your Mac’s Terminal application (Applications/Utilities/Terminal).
- Type the following command into the Terminal, followed by a space – but don’t press the ‘Enter’ key on your keyboard:
lsof
- Open the Trash, find the item that you want to delete, and then drag and drop it into the Terminal window.
- Press the ‘Enter’ key on your keyboard.
- The Terminal will now display a list of all the apps and processes that are using this file. You’ll need to close every item that appears in this list.
Closing an application is typically straightforward, but if the application refuses to close then you may need to force quit it:
- Select the ‘Apple’ logo in your Mac’s menu bar.
- Choose ‘Force Quit…’
- Select the application that’s refusing to close.
- Click ‘Force Quit.’
To close a process, open macOS’ Activity Monitor app (Applications/Utilities/Activity Monitor). Find the process in question, and then click the little ‘Quit’ icon in Activity Monitor’s upper-left corner.
After closing all the applications and processes that were using this file, you should be able to delete the file, as normal.
How to unlock a locked file
It’s impossible to send a locked file to the Trash. If you’re encountering a “file locked” error, then you’ll need to unlock that file before you can delete it:
- Control-click the file in question.
- Select ‘Get Info.’
- Click to expand the ‘General’ section.
- Deselect the ‘Locked’ checkbox.
You should now be able to send this file to the Trash without any issues.
Give yourself permission: Deleting protected files
Often, there’s a good reason why you don’t have permission to delete an item. Perhaps the file is owned by someone else who shares your machine, or maybe it’s a system file that you really shouldn’t be touching.
Whenever your Mac warns that you have insufficient privileges to delete a file, you should pause and question whether you should even be messing around with this file in the first place.
If you do decide to go ahead, then you can give yourself permission to delete this file:
- Control-click the file.
- Select ‘Get Info.’
- Click to expand the ‘Sharing & Permissions’ section.
- Find your username, open its accompanying ‘Privilege’ dropdown menu, and then select ‘Read & Write.’
You should now be able to send this file to the Trash, and empty the Trash as normal.
Empty the Trash from the Terminal
If you’re unsure why the Trash is refusing to empty, then you may be able to resolve this problem by emptying the Trash from your Mac’s Terminal:
- Open a new Terminal window (Applications/Utilities/Terminal).
- Type the following command into the Terminal, followed by a space – but don’t press the ‘Enter’ key:
sudo rm -R
- Open your Trash can.
- Select all the files that you want to delete, and then drag and drop them into the Terminal window.
- Now you can press the ‘Enter’ key on your keyboard.
- When prompted, enter your administrator password.
- Press the ‘Enter’ key.
Delete any file, instantly
When you delete an item, macOS’ default behaviour is to send that item to the Trash, rather than deleting it immediately. You’ll then need to either empty the Trash manually, or wait for the Trash to empty automatically (assuming that you’ve set the Trash to empty periodically based on a schedule).
While this does give you the opportunity to change your mind and recover a file that you sent to the Trash by accident, if there’s a file that you definitely want to see the back of, then you can delete it immediately, rather than simply sending it to the Trash.
- Select the item that you want to delete.
- Use the ‘Option+Command+Delete’ keyboard shortcut.
- Read the onscreen warning, and if you’re happy to proceed, then click ‘Delete.’
Add Comment