<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: T.</title>
    <description>The latest articles on DEV Community by T. (@codebrotha).</description>
    <link>https://dev.to/codebrotha</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F30868%2F43e92cb4-c25e-4b5b-b8de-e14d22dcf4c9.jpeg</url>
      <title>DEV Community: T.</title>
      <link>https://dev.to/codebrotha</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/codebrotha"/>
    <language>en</language>
    <item>
      <title>How to fix macOS corrupt Trash</title>
      <dc:creator>T.</dc:creator>
      <pubDate>Sun, 10 Mar 2019 01:24:07 +0000</pubDate>
      <link>https://dev.to/codebrotha/how-to-fix-macos-corrupt-trash-4jpg</link>
      <guid>https://dev.to/codebrotha/how-to-fix-macos-corrupt-trash-4jpg</guid>
      <description>&lt;p&gt;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... &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpc4ths8cllc4i665owdj.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpc4ths8cllc4i665owdj.gif" width="320" height="240"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;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.&lt;/p&gt;

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

&lt;p&gt;This is how to fix this issue whenever it arises:&lt;/p&gt;

&lt;p&gt;Enter the following commands into Terminal, one line at a time. (The first line will prompt for your password.)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo rm -rf ~/.Trash
sudo rm -rf /Volumes/*/.Trashes
mkdir ~/.Trash
sudo chown $UID ~/.Trash
chmod u+rwx ~/.Trash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pro Tip:&lt;/strong&gt; 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).&lt;/p&gt;

&lt;p&gt;If you don't know how to create a Bash Shell alias, &lt;strong&gt;&lt;a href="https://codeburst.io/how-to-create-shortcut-commands-in-the-terminal-for-your-mac-9e016e25e4d7" rel="noopener noreferrer"&gt;this article&lt;/a&gt;&lt;/strong&gt; explains it.&lt;/p&gt;

&lt;p&gt;Here is the alias I use on my MacBook Pro:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;alias fixTrash='sudo rm -rf ~/.Trash &amp;amp;&amp;amp; sudo rm -rf /Volumes/*/.Trashes &amp;amp;&amp;amp; mkdir ~/.Trash &amp;amp;&amp;amp; sudo chown $UID ~/.Trash &amp;amp;&amp;amp; chmod u+rwx ~/.Trash &amp;amp;&amp;amp; echo "Trash has been reset."'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;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:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Turn off your Mac.&lt;/p&gt;

&lt;p&gt;Press Power button, then quickly hold down command + R button together to boot into Recovery Mode.&lt;/p&gt;

&lt;p&gt;Once your Mac has booted into Recovery Mode, choose Utilities from the menu bar and select Terminal and enter the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;csrutil status
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command will return a response of either "System Integrity Protection status: enabled." or "System Integrity Protection status: disabled."&lt;/p&gt;

&lt;p&gt;If Enabled, type the following command into Terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;csrutil disable
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should see a message stating "Successfully disabled System Integrity Protection."&lt;/p&gt;

&lt;p&gt;Close Terminal and restart your Mac.&lt;/p&gt;

&lt;p&gt;To re-enable SIP, go back into Recovery Mode as you did before and type the following command into Terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;csrutil enable
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should see a message stating "Successfully enabled System Integrity Protection."&lt;/p&gt;

&lt;p&gt;Restart your Mac.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;If issue persists, you may need to re-build your user account:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Log into another admin user. (Create one if no other admin user exists.)&lt;/li&gt;
&lt;li&gt;Delete your main user from System Preferences &amp;gt; Users and Groups.&lt;/li&gt;
&lt;li&gt;Be sure to select the option to “Keep a copy of the home folder”.&lt;/li&gt;
&lt;li&gt;Open Finder &amp;gt; Go &amp;gt; Computer &amp;gt; Macintosh &amp;gt; Users &amp;gt; Deleted Users, and remove “Deleted” from the username, then move back into Users folder.&lt;/li&gt;
&lt;li&gt;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).&lt;/li&gt;
&lt;li&gt;Create the user &amp;amp; when prompted select the option to “Use the existing folder”.&lt;/li&gt;
&lt;li&gt;Restart and login to your original user.&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>macos</category>
      <category>unix</category>
      <category>bash</category>
      <category>alias</category>
    </item>
  </channel>
</rss>
