Emptying Stubborn Files from macOS Trash
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
Related
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.
0 Response to "Emptying Stubborn Files from macOS Trash"
Post a Comment