How to fix macOS corrupt Trash
Tags: macos, unix, bash, alias
Published: 2019-03-10 01:24:07

---
title: How to fix macOS corrupt Trash
published: true
description: 
cover_image: https://thepracticaldev.s3.amazonaws.com/i/dvp128jisjeyw488gh4c.png
tags: macOS, unix, bash, alias
---
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... 

![](https://media.giphy.com/media/XreQmk7ETCak0/giphy.gif)

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
```
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](https://codeburst.io/how-to-create-shortcut-commands-in-the-terminal-for-your-mac-9e016e25e4d7)** 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."'
```
**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
```
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
```
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
```
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.