I’ve got a couple of files (empty directories) in the Trash I can’t delete. I own them, the mode is 777 and whether I use Empty Trash or use rm from the command line (with sudo or running as root) I get “Permission denied”. I tried booting into recovery mode and setting csrutil to disabled but that did nothing. Any ideas? It’s not the end of the world but every time I empty the trash I have to deal with the dialog box about not being able to delete them.
There was a bug once that affected files which had been write-protected by user. Once a file had been made write-protected, it coudn’t be either moved into trash, or be deleted at all - because, it was write-protected. Even fixing file permissions didn’t help.
Could it be possible that you moved such a protected file into trash? Try the following command in Terminal:
sudo rm -rf ~/.Trash/*
then enter your password. This should empty the trash by force.Alternatively:
- Open Terminal and enter
sudo rm
followed by a space. Do not press the Enter key afterwards (this is important). - Now open the recycle bin in the dock and drag the files in the recycle bin into the Terminal window.
- Press the Enter key and enter your password to confirm. Press the Enter key again.
.
Edit: After reading my comment once again: The second sentence should read:
Once a file had been made write-protected, it coudn’t be either moved into trash, or be deleted at all. Even, removing the write-protection by unchecking the tick box in the file information was not possible - because, it was write-protected.
None of these worked.
I’m sorry to hear that. What about another attempt:
- move the files from Trash onto your Desktop
- mount a (otherwise empty) thumb drive or a hard disk
- now move these files onto your thumb drive
Are you able to move the files from your Desktop onto the thumb drive? If not, I’m out of ideas. If yes:
- open Disk Utility
- delete (format) the thumb drive in order to get rid of the files.
Perhaps this works. Good luck.
That didn’t work either but the error message said something about needing it to be downloaded. That reminded me it was originally on OneDrive so I put it back when it started, went to the OneDrive site in a browser and was able to delete it from there. Thanks!
That’s the nasty thing with OneDrive: Usually, your file that you have created is on your computer. So this is considered as “original”. A copy of that file is then uploaded into the cloud.
With OneDrive it is reversed. The file you created on your computer probably is saved to OneDrive immediately, making this the original file. On your computer there is just a copy that acts as an alias.
If you have Microsoft Office as a stand-alone version (e.g. home or student version) installed on your computer, go settings and look where you can change that files are saved onto your computer in order to avoid this in the future (this might not be an option if you use Office 365, as they do not support to change the save location any longer, as far as i recall).
- Open Terminal and enter
Have you tried to repair the permissions or the file system from the Disk Utility?
Yes.
Try booting into Recovery and use Terminal to rm -rf.
Did that, as mentioned in the question.
You said you disabled SIP in Recovery. You did not say you actually tried to delete from Recovery.
I did indeed try deleting them from Recovery with no success.
Try: sudo chflags nochg the_file
Then try to delete the_file
The command should be
nouchg
and it didn’t do anything.