DEV Community

Cover image for How to fix macOS corrupt Trash
Tineyi Takawira
Tineyi Takawira

Posted on • Edited on

How to fix macOS corrupt Trash

In the course of a typical workday, I tend to amass temporary files on my desktop. These may be placeholder images or snippets of code I wrote for later or "borrowed" from Stack Overflow...

Every few hours I will catch a glimpse of this chaos on my desktop and my need to see a clean desktop will compel me to clean it up. Seems simple enough, Trash the files I don't need, and get back to coding.

Except when it isn't so simple, and my system's Trash has become corrupt, showing the message in the image you see above.

This is how to fix this issue whenever it arises:

Enter the following commands into Terminal, one line at a time. (The first line will prompt for your password.)

sudo rm -rf ~/.Trash
sudo rm -rf /Volumes/*/.Trashes
mkdir ~/.Trash
sudo chown $UID ~/.Trash
chmod u+rwx ~/.Trash
Enter fullscreen mode Exit fullscreen mode

When you have finished entering these commands, quit Terminal. Your Trash should now be fixed. Move a file to Trash to make sure it now works properly. Then empty Trash to make sure that works too.

Pro Tip: Create an alias to make your life easier! (Apple engineers can't seem to fix this issue and if your system is affected by this it will happen repeatedly).

If you don't know how to create a Bash Shell alias, this article explains it.

Here is the alias I use on my MacBook Pro:

alias fixTrash='sudo rm -rf ~/.Trash && sudo rm -rf /Volumes/*/.Trashes && mkdir ~/.Trash && sudo chown $UID ~/.Trash && chmod u+rwx ~/.Trash && echo "Trash has been reset."'
Enter fullscreen mode Exit fullscreen mode

Depending on your Mac's permissions, you may have to temporarily disable System Integrity Protection (SIP) for this, here are the steps to do that if necessary:

Turn off your Mac.

Press Power button, then quickly hold down command + R button together to boot into Recovery Mode.

Once your Mac has booted into Recovery Mode, choose Utilities from the menu bar and select Terminal and enter the following command:

csrutil status
Enter fullscreen mode Exit fullscreen mode

This command will return a response of either "System Integrity Protection status: enabled." or "System Integrity Protection status: disabled."

If Enabled, type the following command into Terminal:

csrutil disable
Enter fullscreen mode Exit fullscreen mode

You should see a message stating "Successfully disabled System Integrity Protection."

Close Terminal and restart your Mac.

To re-enable SIP, go back into Recovery Mode as you did before and type the following command into Terminal:

csrutil enable
Enter fullscreen mode Exit fullscreen mode

You should see a message stating "Successfully enabled System Integrity Protection."

Restart your Mac.

If issue persists, you may need to re-build your user account:

  1. Log into another admin user. (Create one if no other admin user exists.)
  2. Delete your main user from System Preferences > Users and Groups.
  3. Be sure to select the option to “Keep a copy of the home folder”.
  4. Open Finder > Go > Computer > Macintosh > Users > Deleted Users, and remove “Deleted” from the username, then move back into Users folder.
  5. Re-create the user in Users and Groups, making sure to use the same username (Home folder name), and password. (And choose administrator if it was one).
  6. Create the user & when prompted select the option to “Use the existing folder”.
  7. Restart and login to your original user.

Top comments (3)

Collapse
 
buster95 profile image
Walter Corrales

this was helpful to me, I had a problem with the trash looks like a problem with permissions but I had to deactivate system integrity protection, thanks a lot

Collapse
 
aliofhashemi profile image
ALI HASHEMI

Thanks, it is working perfectly.
🤟

Collapse
 
rodrigozamorano profile image
Rodrigo Zamorano

Thank you very much!