7 Exercise Tips How to Stream 'Rabbit Hole' Roblox's AI Efforts 9 Household Items You're Not Cleaning Enough Better Sound on FaceTime Calls 'X-Ray Vision' for AR 9 Signs You Need Glasses When Your Tax Refund Will Arrive
Want CNET to notify you of price drops and the latest stories?
No, thank you

Trash problems in OS X? Reset it!

Despite its simplicity, periodically you may run into problems with how the trash behaves, such as the inability to remove files from it, or the system warning about files on local drives being removed immediately.

The OS X trash is a relatively simple concept: you put something in it as a temporary location before you throw it out, and when you do throw it out, it is--for the most part--permanently removed. The trash has been this way for years, with the only additional option being the recent "put away" feature in Snow Leopard. Despite its simplicity, periodically, you may run into problems with how the trash behaves, such as the inability to remove files from it, or the system warning about files on local drives being removed immediately.

Some items will be deleted immediately, instead of being temporarily placed in the trash. Screenshot by Topher

The trash works by using hidden folders to temporarily store files, and then the system runs permanent deletion commands on those folders when you use the "Empty Trash" option in the Apple menu (part of me still wants to say the "Special" menu). By default, the file's directory entry is only removed, and you may be able to retrieve it with third-party scanning software as long as the space on the drive containing the data is not overwritten; however, using the option to secure-empty trash effectively cancels this capability and makes the deleted items irretrievable.

The temporary folders that are used are the following (NOTE: These are hidden):

This folder contains files on the local boot disk that were thrown away by your user account. If you have a file on the desktop and drag it to the trash, it will be moved to this folder.

At the root of every drive is a "Trashes" folder that contains files on that drive that have been moved to the trash on a system that has used the drive. This is true for internal and external drives, with the exception of networked drives (NAS or computer shares). If a file appears in the trash when you attach an external drive, then it is in that drive's "Trashes" folder.

To tackle problems with the trash, the first thing to do is check which trash folder is being used for the files, since more than likely your inability to access the folder is causing the problem; however, you need to know which folder it is. To do this, compare your problem to the following scenarios:

  • Problematic files in the trash disappear when you eject a drive? The problem is with your "Trashes" folder at the root of that drive.

  • Problematic files stay around when you eject and unmount all but the boot drive? The problem is with your "username/.Trash" folder.

  • You cannot place a file into the trash (system wishes to delete it immediately): is the file in your home folder or Desktop? If so, the problem is with your "username/.Trash" folder; however, if the file is on an external disk, then it is with the "Trashes" folder at the root of that drive.

Once the folder has been identified, the best way to fix the problem is to delete it and have the system recreate it by logging out and logging back in; or, in the case of the "Trashes" folder at the root of the drive, the folder is recreated when the drive is unmounted and mounted again.

Here are the ways to delete the respective "Trash" or "Trashes" folders. Keep in mind that when you do this all files currently in the trash will be permanently deleted. Additionally, these folders are hidden so we will access them using the Terminal.

1. The "username/.Trash" folder

Open the Terminal and run the following command. After this is entered in the Terminal, you will be asked for your password (which will not be displayed) before the command is run.

sudo rm -rf ~/.Trash

2. The ".Trashes" folder at the root of each drive.

The easiest way to delete a problematic ".Trashes" folder at the root of a specific hard drive is to run the following steps after opening the Terminal:

  • Enter "sudo rm -rf" followed by a single space.

  • Drag the specific hard drive to the terminal (do not press enter yet, or if you have and it is asking for a password at this point, press Control-C or close the terminal window and start again).

  • Press backspace once to remove the automatically placed space, and then complete the command with the following:

  • /.Trashes

  • The command should now look something like the following (your drive may be a different name than "Backup", and may contain spaces in it with backslashes before them):

  • sudo rm -rf /Volumes/Backup/.Trashes

  • With this command entered, press "Enter" or "Return" and supply your administrator password. Then eject the drive and plug it back in. In the case of internal hard drives or partitions, either use Disk Utility to remount the drive, or restart the computer.

CAUTION: Misuse of the "rm" command may result in data loss! Be sure you enter the command as stated above so the full path points to the .Trash or .Trashes folders, and does not contain a space without a backslash in front of it (/Volumes/My\ Backup/.Trashes). Most times, an error in the file path will result in no actions being taken; however, the following is an error in the command's syntax that will result in the entire contents of the named hard drive being erased if you continue:

sudo rm -rf /Volumes/Backup/ .Trashes

The space before ".Trashes" tells the command to target all files and folders in the /Volumes/Backup/ drive for deletion instead of just those in the ".Trashes" folder.

Have questions or comments? Post them below.
Be sure to check us out on Twitter and the CNET Mac forums.