Empty the Trash from Terminal in Mac

In this guide, we will explain how to empty the Trash on your Mac using the Terminal, a useful method for clearing out unwanted files when the Trash won’t empty using the regular method.

Introduction to Trash on Mac

When you delete files on your Mac, they are moved to the Trash, where they remain until you manually empty the Trash. Sometimes, certain files in the Trash may refuse to delete due to permission issues or other errors. In such cases, using the Terminal provides a powerful way to empty the Trash completely.

By following the steps in this guide, you can easily clear the Trash using Terminal commands.

Method 1: Empty Trash Using the “rm” Command

The rm command allows you to delete files and directories from the command line. This method will force-delete the contents of the Trash folder.

Follow these steps to empty the Trash using Terminal:

Step 1: Open the Terminal app on your Mac. You can find it in Applications > Utilities or by searching for “Terminal” in Spotlight.

Step 2: In the Terminal window, type the following command to navigate to the Trash directory:

cd ~/.Trash
Empty Trash from Terminal in Mac

Step 3: To force delete everything in the Trash folder, use the rm command followed by the -rf flag, which stands for “recursive” and “force”. This will delete all contents of the Trash without confirmation:

rm -rf *

Step 4: Press Enter.

Press y if you like to remove the contents.

This command will empty the Trash completely.

Step 5: To verify that the Trash has been emptied, you can check the Trash folder on your Mac. It should now be empty.

Note: The rm -rf * command is very powerful, so be cautious when using it, as it will permanently delete all files in the Trash folder. Make sure you don’t accidentally run this command in the wrong directory.

Method 2: Empty Trash Using “sudo” for Protected Files

Sometimes, files in the Trash are protected or have special permissions that prevent them from being deleted. In such cases, you can use the sudo command to empty the Trash as an administrator.

Follow these steps to empty the Trash using “sudo”:

  • Step 1: Open the Terminal app.
  • Step 2: Type the following command to navigate to the Trash directory:
  • cd ~/.Trash
  • Step 3: Use the following command to force delete all files in the Trash with administrative privileges:
  • sudo rm -rf *
  • Step 4: You will be prompted to enter your Mac’s administrator password. Type it and press Enter.
  • Step 5: The protected files in the Trash will now be deleted.

Note: Be careful when using sudo with the rm -rf command, as it grants administrative access and can permanently delete files, bypassing any recovery mechanisms.