Emptying Stubborn Files from macOS Trash

Full Trash Can

Full Trash Can

Question:

Michael writes: I have a file stuck in my Trash. I’ve tried to permanently delete it, but it doesn’t want to stay gone. My friend told me you talked about this problem on one of your episodes.  If you can refer me to that episode, I’ll take a listen. Thanks for being a resource to the masses of Mac users out there.

Answer:

Let’s start from the beginning and review all of the ways one can put items in, as well as empty the Trash, of course getting progressively geekier as we move on.

To put item(s) in the Trash, once can simply drag the item(s) to the Trash icon, or move the highlighted file(s) to the Trash using the keyboard combo Command-Delete. If you realize you made a mistake, you can Undo the operation by choosing File > Undo, or use the keyboard combo Command-Z.  If you’d like to delete highlighted items immediately, you can hold down Option and select File > Delete Immediately…. Alternately, you can use keyboard combo Command-Option-Delete. Either way, you’ll received a confirmation dialog that the operation is permanent and can’t be undone.

If there are files in the Trash, which you can confirm visually because you’ll see items in the Trash, you can empty it by either choosing Finder > Empty Trash…, or using keyboard combo Shift-Cmd-Delete. You’ll be presented with a confirmation dialog asking if you’re sure.  You can also hold down Option and select Finder > Empty Trash, or use keyboard combo Shift-Option-Command-Delete. Notice that since there isn’t a trailing ellipsis after the choice, it will be done immediately without a confirmation dialog.

If these fail, it’s time to break out the big guns and go to the Terminal.  Depending on if the files are in the Trash of your boot drive, or an external drive, you’ll need to navigate to a different directory to try and manually delete the files.

Trash on Your macOS Boot Drive

For your boot drive, after you start the Terminal, you should be in your home directory.  You can then navigate to the hidden Trash directory by entering the following:

cd .Trash/

This can be made a bit easier by using the filename completion feature found in most shells; if you enter the first few characters of a file, in this case .T, and hit Tab, it should complete the name of the file after which you can press Return.

Once you’re in the .Trash/ directory, you can use the “ls” command to see the files(s) in the trash, and use the “rm” command, along with the filename completion trick, to manually remove the files.  You may be asked for confirmation.  You can use a slightly more powerful version of the command “rm -f” that won’t ask for confirmation.  And for goodness sake, before using “rm” you may want to do a “pwd” (print working directory) to confirm that you are indeed in the .Trash/ directory.

Trash on an External macOS Drive

Then there’s the matter of removing files on an external, direct connected drive.  The path to get to this is quite a bit more complex than the boot drive, and you’ll be well served by using the filename completion feature of your shell, making small incremental steps,  starting with:

cd /Volumes/

and then doing an “ls” seeing what comes next, typing in the first few characters of the volume or directory, until you get to something like this, for a drive that I’ve named “1 TB HD” and for which my user id is 505.

cd /Volumes/1\ TB\ HD/.Trashes/505

As you can see, there are some differences, first, the mount point for this drive starts in the /Volumes directory, second, because the name of my drive is “1 TB HD” and contains spaces, the “\” is used as a delimiter, third, the directory is “.Trashes” and not “.Trash” like our boot drive, and last, the file(s) are inside of a directory named with my user ID.  For a list of the user IDs on your system, you can enter the “id” command via the Terminal.  Once you’re in the directory, use the “ls,” “rm” and “rm -f” commands as appropriate.

File Permissions in Trashed Files

If you still can’t get rid of the files, their permissions may be messed up.  If you highlight a file in the Trash and do a File > Get Info, or use keyboard combo Cmd-I, you’ll get a list of various file attributes, with Sharing and Permission on the bottom.  Make sure that the Name of the Owner includes (Me), and the Privilege is “Read & Write.”

For an application that we suspect does most of these things underneath the covers, we’ve found that Trash It! is a fine product, and confirmed that it runs under the latest version of macOS.

If you still can’t delete the files in the Trash, your disk is likely corrupt or dying, and you should consider a disk repair utility or replacing the drive.

About MGG Answers:

Each week Dave Hamilton and John F. Braun provide some great troubleshooting advice to listeners of the Mac Geek Gab podcast. Here with MGG Answers we share some of those tips with the rest of the world!

2 thoughts on “Emptying Stubborn Files from macOS Trash

  • Here’s what I do. In the Terminal type:

    su – (or use sudo)

    sudo rm -dPRrvW (drag the contents of the trash here) Enter

    If asked, answer “y”. Smile (works 99% of the time)!

  • I had several files in my trash that had been on external drives and would fail to delete when I emptied the trash no matter how I tried. They returned an error stating that the programs were in use, even though they weren’t and the file size was zero K.

    Apple’s senior tech people finally suggested that I migrate everything else off the external drives and reformat them, then move everything back. These were 4TB and 5TB drives that were fairly full so I wasn’t too excited to do this so I lived with the problem instead.

    For future reference in case anyone else ever has this problem the better solution is to:
    1) move the files out of the Trash and back to their respective external drives
    2) create a new user account (and probably make it an Admin account, at least I did)
    3) switch user to the new account
    4) move the un-deletable files from the external drives back to the Trash
    5) if you try emptying the Trash you will see that the problem still persists (so you can skip this step)
    6) log out of the new user account and log back into your original Admin account
    7) drop the new user account and don’t archive it

    Presto, the files are gone!

Leave a Reply

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