Site icon ChrisWrites.com

How to delete stubborn “in use” and locked files

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:

lsof

Closing an application is typically straightforward, but if the application refuses to close then you may need to force quit it:

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:

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:

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:

sudo rm -R

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.

Exit mobile version