How-To OS X

How to Delete Any File or App from your Mac

delete files macos sierra

Are you trying to show an app or file the door, but something is preventing you from deleting it?





There’s several reasons why a file or app may insist on hanging around long after its welcome has run out. In this article I’m going to show you how to delete even the most stubborn file or application – including the suite of Apple apps that come baked into every MacBook.


Problem: A file is being used by another app or process

If you’re getting a ‘File in use’ message whenever you try and drag a file to the Trash, that means an app or process is currently using this file. You’ll need to hunt down the culprit, and close it.

Start by checking what apps you have open and closing any that you suspect might be accessing the file in question, then try deleting the file again. If you’re still seeing the ‘File in use’ message, then it’s time to take a closer look at exactly what’s running on your MacBook, by launching the Activity monitor app (‘Applications’ > ‘Utilities’ > ‘Activity Monitor).

In Activity Monitor, select either the ‘CPU’ or ‘Memory’ tab and spend some time exploring the list of currently-running apps and processes. Could any of these be using the file you’re trying to delete? If you spot a likely candidate, then select it and give Activity Monitor’s ‘Quit Process’ icon a click.

quit-process

Just be wary of closing a process when you don’t fully understand what that process does, as some processes are essential to the smooth running of your Mac. If you’re unsure, then do some research by entering the name of the mystery process into your favourite search engine and exploring some of the results.

Problem: The file is locked

If you’re getting a ‘File is locked’ message, then you’ll need to unlock that file before you can delete it:

  • Control-click the file in your Finder.
  • Select ‘Get Info’ from the menu that appears.
  • Expand the ‘General’ section, if it isn’t expanded already.
  • Deselect the ‘Locked’ checkbox.

If the ‘Locked’ checkbox is greyed out, then this means you don’t have permission to modify the file (we look at how to change a file’s permissions in the next section, so skip ahead if you can’t currently access the ‘Locked’ checkbox).

You can also unlock a file using the Terminal that comes pre-installed on every MacBook. To launch Terminal, click the ‘Spotlight’ icon in your MacBook’s menu bar and enter ‘Terminal’ into the search bar that appears.

spotlight-search

This launches the Terminal window. Input the following command (being sure to replace location/nameoffile.extension with your own filename and file path) and hit the ‘Enter’ key on your keyboard:

chflags nouchg location/nameoffile.extension

Once the file is unlocked, you should be able to go ahead with the delete.

You don’t have permission to access the file

Permissions can prevent you from deleting a file in two ways:

  1. The file is locked, and you don’t have permission to unlock it.
  2. You see an error message whenever you try to delete the file.

To get permission to modify a file, Control-click the file in question and select ‘Get Info.’ In the ‘Get Info’ window, find the ‘Sharing & Permissions’ section and expand it. Here you’ll find a list of all the user accounts associated with your MacBook, along with each account’s permissions regarding this specific file: Read Only, Read & Write, or No Access.

If you spot a padlock icon in the bottom-right of this menu, then you’ll need to click it and enter your admin password before you can make any changes.

lock-icon

Find your user account in the list, click its corresponding set of arrow icons and select ‘Read & Write’ from the dropdown menu.

read-and-write-permissions

You now have permission to modify this file – and that includes unlocking the file, and deleting it.

If all else fails: Force Delete

If the file is unlocked and you have read and write permissions, but you’re still struggling to delete the file, then you can force-delete it by issuing Terminal commands.

Just be aware that when you force-delete something, it gets permanently deleted as soon as you hit the ‘Enter’ key. There’s no way to recover a force-deleted file!

The Terminal can also delete files you wouldn’t normally be able to remove, and sometimes there’s a very good reason why MacOS tries to prevent you from deleting something. Before going ahead with a force-delete, consider whether removing this file might have a negative impact on other applications, or even your MacBook as a whole.

If you’re unsure, then it’s always best to err on the side of caution and either leave the file well alone, or make a full backup before proceeding with the force-delete, so you have something to restore if it all goes wrong.

To force-delete a file, open the Terminal (either by performing a Spotlight search for the word “Terminal,” or by going to Applications>Utilities>Terminal). Then, type the following into the Terminal but don’t press the ‘Enter’ key:

rm -

Drag the file you want to delete onto the Terminal, as this will automatically add the filename and its entire path to the Terminal command (a handy shortcut!) Double-check that this really is the file you want to force-delete, then hit the ‘Enter’ key.

This command works on files only, so if you’re struggling to delete a directory you’ll need to enter a different command.

To delete an empty directory, use:

rmdir location/directoryname

To delete a directory plus all of its contents, run:

rm -R  /Users/jessicathornsby/Desktop/mydirectory

Since this removes the entire contents of the directory and all its subfolders, it’s always a good idea to explore every part of the directory before running rm -R, just to make sure there’s nothing you want to hang onto.

Problem: The Trash Won’t Empty

Sometimes, a file may make it as far as the Trash and then get stuck there.

Maybe you’re clicking ‘Empty Trash’ and it seems to be working, but when you open the Trash folder you realise that it either hasn’t emptied at all, or that one or more files have been left behind. Alternatively, maybe everytime you try and empty the Trash you get an error message, something along the files of “Operation cannot be completed because….”

Whatever Trash-related issues you’re experiencing, you can often resolve this issue by performing a ‘Force Empty.’ To invoke this feature, simply hold the ‘Option’ key while selecting the regular ‘Empty Trash’ option.

Alternatively, if you know which file is preventing the Trash from emptying as normal, then you may want to look into why this particular file is causing problems. Find the file in your Trash folder, then Control-click it and select ‘Get Info.’ Check whether the file is locked, and whether you have ‘Read & Write’ permissions for that file, as both of these can interfere with the Trash can’s normal operations.

If none of these techniques work, then you can force-delete files that are already in the Trash, using the Terminal. Point the Terminal at your Trash folder:

cd ~/.Trash

Then tell it which file to delete:

rm -- filename.jpg

How to Delete System Apps

You may have noticed that a new MacBook is never truly a blank slate, as every Apple product comes pre-loaded with Apple apps, such as Safari, Mail, FaceTime and Photos.

While you may use some of these apps on a day-to-day basis, chances are you won’t use all of them. Maybe you prefer a non-Apple alternative, such as Chrome, or maybe you simply have no use for a particular app – I can honestly say I’ve never launched the Chess app that came with my MacBook!

Any apps you don’t use just sit around, taking up space and cluttering your ‘Applications’ folder for no good reason, however if you’ve ever tried to uninstall a system app, you’ll know that it’s impossible to delete them the normal way.

mail-cannot-be-deleted

In this section, I’m going to show you how to uninstall any app, including system apps. But first, consider whether removing the app you have in your crosshairs is likely to have a serious impact on other applications, or even the operating system itself. If you do decide to go ahead, then you may want to take some extra precautions by creating a full backup first.

In order to delete any of your MacBook’s default apps, you’ll need to temporarily disable System Integrity Protection (SIP), which is something you should never do lightly. SIP is designed to help protect your MacBook from malware by preventing anyone from accessing and modifying system files, so if you do disable SIP then you should make the effort to delete your system apps and re-enable SIP as quickly as possible.

To disable SIP, boot into Recovery by restarting your Mac and holding the ‘Command-R’ buttons until you see the Apple logo and progress bar. Once in Recovery mode, open the ‘Utilities’ menu, select ‘Terminal’ and enter the following command:

csrutil disable

You’ll see a message that SIP has been disabled. At this point, you can modify your system files, so exit Recovery mode and restart your MacBook as normal. Open the Terminal and point it at your ‘Applications’ directory:

cd /Applications/

You can now delete any app, by running the following command:

sudo rm -rf Chess.app/

Enter your admin password when prompted, and that’s it – the app will be permanently deleted.

As soon as you’ve finished deleting apps, you should re-enable SIP by booting into Recovery, opening the Terminal and running the following command:

csrutil enable

You’ll see a message confirming that SIP is back up and running, which means your MacBook once again has an extra layer of protection against malware.

Before you go

After spending over 20 years working with Macs, both old and new, theres a tool I think would be useful to every Mac owner who is experiencing performance issues.

CleanMyMac is highest rated all-round cleaning app for the Mac, it can quickly diagnose and solve a whole plethora of common (but sometimes tedious to fix) issues at the click of a button. It also just happens to resolve many of the issues covered in the speed up section of this site, so Download CleanMyMac to get your Mac back up to speed today.

mac-pc

About the author

Chris

I've been a passionate evangelist for Apple and the Macintosh throughout my working life, my first love was a Quadra 605 working with a small creative agency in the south of Norfolk UK in the mid 1990's, I later progressed to other roles in other Macintosh dominated industries, first as a Senior graphic designer at a small printing company and then a production manager at Guardian Media Group. As the publishing and printing sector wained I moved into Internet Marketing and in 2006 co-founded blurtit.com which grew to become one the top 200 visited sites in the US (according to Quantcast), at its peak receiving over 15 million visits per month. For the last ten years I have worked as an Affiliate and Consultant to many different business and start ups, my key skill set being online marketing, on page monetisation, landing page optimisation and traffic generation, if you would like to hire me or discuss your current project please reach out to me here.

You can also follow me on: and

1 Comment

Click here to post a comment

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.