Empty Trash Not Working on macOS Terminal: Troubleshooting and Solutions
If you have encountered an error message when trying to empty the trash using the Terminal on your macOS, you are not alone. This article will cover the key concepts related to this issue, provide detailed context, and offer solutions to help you resolve it.
Understanding the Problem
When attempting to empty the trash using the Terminal with the command /Users/username/.trash, some users might receive the following error message:
sudo rm -rf ~/.trash
geterrormessage: /Users/username/.trash
Operation not permitted
no matches found: ...
This error occurs because the Terminal cannot delete the files in the Trash due to permission issues.
Why Does This Issue Happen?
When you delete files using the Finder, they are moved to the Trash, which is a hidden folder in your home directory (~/.trash). This folder has specific permissions that prevent unauthorized access or deletion of its contents. If you attempt to delete files from the Terminal, you might encounter a "permission denied" error.
Solutions for Emptying the Trash Using the Terminal
Here are some methods you can try to resolve this issue and successfully empty the Trash using the Terminal:
-
Change the permission of .Trash folder: Before attempting to delete the files in the Trash, you can first change the permission of the .Trash folder by running the following commands in the Terminal:
sudo chown -R $USER:staff ~/.Trash
sudo chmod -R 755 ~/.Trash -
Use the 'sudo' command: If changing the permission of the .Trash folder does not help, you can try using the 'sudo' command, which will allow you to delete the files with administrative privileges:
sudo rm -rf ~/.Trash*Please note that using 'sudo' can be risky if you are not cautious. Be sure to specify the correct path.
-
Empty the Trash in Safe Mode: If neither of these methods work, you can try booting your macOS in Safe Mode and then emptying the Trash. Safe Mode will temporarily disable some third-party software and helper tools, allowing you to delete the files.
To boot in Safe Mode: Press the Shift key immediately after restarting your Mac and hold it until you see the login screen.
Additional References
- Apple Support: How to use the Terminal on your Mac
- StackExchange: Can't empty trash via Terminal
- OS X Daily: How to Fix 'Can't Empty Trash' Error on Mac OS X