Solving Trash Problems
A variety of issues can result in making it difficult or impossible to either move files to, or empty, the Trash in Mac® OS X. This FAQ, derived from our book Troubleshooting Mac OS X, covers the following Trash-related topics:
About the Trash in Mac OS X
Mac OS X introduced a new architecture for Trash:
- Each user has their own private, hidden, and invisible Trash folder, located in their Home folder. The UNIX® directory path for this folder when logged in to your account is ~/.Trash.
- Because each user's Trash is private, viewing the contents of the Trash shows only objects that you have placed into the Trash.
- If you have secondary hard drives or other writable volumes connected to your Mac, each contains an invisible Trash folder named .Trashes at the root (top) level of the volume, which in turn contains an invisible Trash folder for each user.
- When you open Trash to view its contents, it appears that all of the objects you have trashed are in a single Trash folder. In reality, Trash is displaying a list that is the union of the contents of all of the individual Trash folders associated with your account, on all writable volumes.
Techniques for solving Trash problems
Trash utilities for eradicating troublesome files
You may want to download and install the freeware utility Trash It! or the shareware utility Cocktail. Using one of these utilities is often the fastest way to Trash recalcitrant files.
Note: Be sure to employ a version of the utility that is compatible with the version of Mac OS X you are using.
Force the Trash to empty using the Option key
This technique uses a hidden feature of Mac OS X to force the Trash to empty. Perform the following steps in the order specified:
- Press and hold the mouse button on the Trash icon in the Dock. The context menu for Trash will display.
- Press and hold the Option key or the Shift-Option keyboard combination,
- Select Empty Trash from the context menu for Trash.
- Release the keys pressed and held in step 2.
Empty and recreate an account's Trash
The following procedure will "kill two birds with one stone." It will both:
- Empty the Trash of an affected account.
- Create a new ~/.Trash directory, with correct ownership and permissions, for that account.
Perform the following steps in the order specified:
||If the affected account is protected by FileVault, log in to the affected account, then switch to and log in to your Admin account via Fast User Switching. Otherwise, log in to your Admin account.
||Open Terminal, located in the Macintosh HD > Applications > Utilities folder.
At the Terminal prompt, type one of the following commands:
|If the affected account is:
||Then type the Terminal command:
|Your Admin account:
||sudo rm -ri ~/.Trash
|Another user account:
||sudo rm -ri /Users/user_name/.Trash
where user_name is the short name of the affected account.
- There is a single space after each of the terms sudo, rm, and -ri in the command.
- Assure you have typed the command exactly as specified before proceeding: typographical errors in this command can have dire consequences, including erasing your hard drive!
||Type your Admin password when prompted, then press Return.
||Type y for yes in response to the subsequent prompts to delete each file in the trash and finally the affected .Trash folder itself. The prompts are finished when the Terminal prompt returns.
||If the affected account is your Admin account, log out. If the affected account was another user account that is logged in via Fast User Switching, log out of that account.
||Log in to the affected account. It will now have a new, working, and empty Trash.
Steps 1-6 remove all files in the affected account's Trash as well as deleting the hidden and invisible ~/.Trash directory for that account. The remaining steps result in recreating the affected account's Trash, with proper ownership and permissions.
Resolving common Trash problems
Moving locked files to the Trash
Mac OS X 10.2 - 10.4 prevent moving locked files to the Trash; Mac OS X 10.5 and later permit locked files to be moved to the Trash.
Locked files display a lock badge in the lower-left corner of their icons. Under Mac OS X 10.5 and later, the lock badge only appears if Show icon preview is deselected in the View Options (View > Show View Options) of the Finder® window containing the locked file.
Use the following procedure to unlock a file:
- Open the Info window for the file by either:
- Selecting the files icon in Finder and pressing the Command-I keyboard combination.
- Control-clicking the files icon in Finder and selecting Get Info from the files context menu.
- In the General panel of the file's Info window, deselect the Locked checkbox. The check mark will disappear, indicating the file is now unlocked.
- Note: If the checkbox immediately returns to the selected (checked) state, then this indicates that the file's system immutable flag has been enabled. This means that you cannot unlock the file until its system immutable flag is disabled: see our "Immutable flags" FAQ.
- Close (Command-W) the Info window for the file.
- Trash the file.
Locked files in the Trash
Try one or more of the following methods to delete locked files in the Trash:
Files in use by other applications
Use one or more of the following methods if you receive a message indicating that a file can neither be moved to the Trash, nor emptied from the Trash, because it is "in use" by another application.
- Quit the application that is using the file. This will usually permit you to then move the file to the Trash or to empty the Trash.
- If you are unsure of the application that has the file "in use," the Terminal command lsof can tell you the name of the process or application that Mac OS X considers to be using the file, as follows:
- Click the Trash icon in the Dock. A Finder window opens showing the contents of your Trash.
- Open Terminal, located in the Macintosh HD > Applications > Utilities folder.
- Position and resize, if necessary, both the Finder window showing the Trash and the Terminal window so you can simultaneously see both windows fully.
- At the Terminal prompt type lsof followed by a single space, but do not press Return yet.
- Drag and drop the file "in use" from the Trash the Finder window opened in step 1 to the Terminal window opened in step 2. The path to the file will appear after the lsof command typed in step 3, i.e. you will see
- lsof /path_to_file
- Press Return.
- If the file is "in use" then the output from lsof will list the names of the applications or processes which claim to be using the file under the first column heading, COMMAND.
- If the file is "in use" by an open application, Quit (Command-Q) that application. If a background process has the file "in use," use Activity Monitor to terminate that process.
- Note: One must be careful when terminating processes as certain background processes are needed for Mac OS X. Quitting processes like loginwindow or kernel_task could force you off your account, freeze your Mac, or cause a kernel panic. If you do not know what effect quitting a process may have, do not quit the process.
- Force the Trash to empty using the Option key.
- Log out, log in, and then attempt to empty the Trash.
- Restart your Mac, log in, and then attempt to empty the Trash.
- Use one of the recommended Trash utilities.
- Empty and recreate the affected account's Trash.
Insufficient privileges needed to trash an object
Warning: If Mac OS X informs you that you have insufficient privileges to delete a file, this may be because you are attempting to delete a System-related file. You should not delete System-related files unless you are absolutely sure you know what you are doing. Deleting System-related files could render your system unusable.
If you are informed that you have either insufficient privileges or insufficient permissions to trash a file or folder, you may be able to trash the object in question using the following procedure.
- Make yourself the Owner (Mac OS X 10.4 and earlier) of the file or add yourself under Name (Mac OS X 10.5 and later) for the file, with Access (Mac OS X 10.4 and earlier) or Privilege (Mac OS X 10.5 and later) of Read & Write, using the instructions in the "Setting Permissions" Mac Help document corresponding to the version of Mac OS X you are using.
- Note: If you find that you already have the correct permissions to delete the file in question and the file is not locked, then this indicates that the file's system immutable flag has been enabled. This means that you cannot delete the file until its system immutable flag is disabled: see our "Immutable flags" FAQ.
- Trash the file.
Incomplete Internet downloads under Mac OS X 10.2
Downloads which fail to complete can sometimes leave you with files which can neither be moved to the Trash nor emptied from the Trash.
- If the downloaded file is in the Trash, try one or more of the following procedures to empty the Trash:
- If the downloaded file cannot be moved to the Trash, try the procedure in the AppleCare® Knowledge Base document "Mac OS X 10.2: Cannot Delete an Incomplete Copy or Download." In particular, try the TextEdit tip.
Files dragged to the Trash "will be deleted immediately" alert
When dragging files to the Trash from removable media or a shared network volume, it is common for Trash to inform you that the files will be deleted immediately. This appears to have been a design choice due to every writable volume having its own hidden Trash folder. If you ejected the removable media or shared network volume before emptying the Trash, the files you thought were deleted would still be in .Trashes folder at the root (top) level of that volume. Hence Mac OS X immediately deletes files moved to the Trash from removable media and shared network volumes. This also depends upon the firmware of the device informing Mac OS X that it is a removable media device. Some removable storage devices identify themselves as hard drives, meaning that items remain in the .Trashes folder if the removable storage device is ejected before the Trash is emptied and will reappear in the Trash when the device is again connected to your Mac.
If you are not dragging files from removable media or shared network volumes to the Trash and are informed that files dragged to the Trash "will be deleted immediately," there are three possible causes:
- You are either no longer the Owner of your Home folder, do not have Access of Read & Write to such, or both.
- Your account's Trash, i.e. your ~/.Trash directory, has been deleted.
- You no longer are the owner of your account's Trash.
To resolve this problem, proceed as follows:
- Assure you are the Owner (Mac OS X 10.4 and earlier) and have Access (Mac OS X 10.4 and earlier) or Privilege (Mac OS X 10.5 and later) of Read & Write on your Home folder:
- In Finder, press the Command-Shift-H keyboard shortcut. A Finder window opens showing the contents of your Home folder.
- Press the Command+I keyboard shortcut. The Info window for your Home folder opens.
- Select the Info window.
- Open the disclosure triangle for the Ownership & Permissions panel (Mac OS X 10.4 and earlier) or the Sharing & Permissions panel (Mac OS X 10.5 and later) in the Info window.
- If using Mac OS X 10.4 or earlier, open the disclosure triangle for the Details panel within the Ownership & Permissions panel.
- If you are not listed as Owner (Mac OS X 10.4 and earlier) or under Name (Mac OS X 10.5 or later) or do not have either Access (Mac OS X 10.4 and earlier) or Privilege (Mac OS X 10.5 and later) of Read & Write, then correct these issues using the instructions in the "Setting Permissions" Mac Help document corresponding to the version of Mac OS X you are using.
- Warning: When using the instructions in the Mac Help document, do not use the Apply to enclosed items option, if available.
- Note: Users of Mac OS X 10.5 or later can start up from their Mac OS X Install DVD and use the Reset Home Directory Permissions and ACLs function of the Reset Password function of the Utilities menu.
- Close the Info window.
- Try to place objects in the Trash. If so, the problem is solved: stop here. Otherwise, proceed to the next step.
- Verify that your ~/.Trash directory exists:
- Open Terminal, located in the Macintosh HD > Applications > Utilities folder.
- At the Terminal prompt, type the following command exactly as written:
- ls ~/.Trash
- Press Return.
- If the response contains "No such file or directory" then:
- Either log out of your account or restart your Mac.
- Log in to your account. You should now be able to add objects to the Trash: stop here.
- Otherwise, proceed to the next step.
- Empty and recreate your account's Trash.
There are rare issues which can inhibit emptying the Trash. These include immutable files and files on which the system immutable bit has been set. If an object cannot be deleted using any of the preceding methods, you may have encountered this rare situation. Dealing with immutable flags is covered in our "Immutable flags" FAQ.