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.
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.
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:
- The file is locked, and you don’t have permission to unlock it.
- 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.
Find your user account in the list, click its corresponding set of arrow icons and select ‘Read & Write’ from the dropdown menu.
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:
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:
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:
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.
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:
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:
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:
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.
Speed Up Your Mac in 3 Easy StepsiDoctor will improve your Mac performance and make it run almost as fast as it was when you bought it.
- Download & Install iDoctor
- Diagnose your Mac for problems
- Remove all items safely