How to clear Trash after deleting old user profiles on macOS Catalina? [duplicate]
I probably did something that I was not supposed to do and now I ran into some kind of problem.
I deleted two old user accounts from my Mac inside System Preferences to get some space back. However the space did not become more so I checked the hard drive and found the two user folders still being there.
So I deleted both manually, which was probably not the best idea. They went to the Trash. However when trying to clear my Trash, the following error occurs:
The operation can't be completed because some items had to be skipped. For each item, choose File > Get Info, make sure "Locked" is deselected, and then check the Sharing & Permissions section. When you are sure the items are unlocked and not designated as Read Only or No Access, try again.
Next I tried to delete the two folders via Terminal using this command:
sudo rm -rf ~/.Trash/
This did not work either, I got the following error: Operation not permitted
Does anyone have any idea how to solve this problem. Thanks for your help in advance.
I had a similar problem. I have an iMac running Catalina 10.15.7 but I think my solution will work for any recent OSX version.
Basically, I had an unwanted user folder inside my Users folder but this user didn't appear in the System Preferences > Users & Groups menu and so, it appeared that I couldn't delete it from there.
If that's the problem you face then, go to the Users & Groups menu, authenticate yourself (click on the padlock and enter your credentials), then click on the '+' to add a new user. Give this user exactly the same name as the unwanted user you want to delete. The new user will be created in Users & Groups. Now click on the '-' to remove that user. You will see a dialogue box asking you to choose from 4 options. The one you want is 'Remove the user's home folder from the computer'. Click OK and you'll find the unwanted user folder inside your Users folder is no longer there.
You can find more instructions on this here : Delete a user or group on Mac - Apple Support
But, unfortunately, I only discovered the above solution AFTER I'd made the mistake of dragging the unwanted user folder to the trash. Once the unwanted user is in the trash, there appears to be nothing you can do to remove it by any of the normal means - if you try to empty the trash, you get a system message advising that 'Voice Trigger' is in use and another that says 'Library' is in use. I tried dragging it back to the Users folder and my desktop and it just created a copy and left the original in the trash; I tried the 'delete immediately' option; I changed the permissions on the folder to allow an Administrator to read & write (and hopefully delete - but that didn't work); I tried a number of Terminal commands; I tried installing an app called iTrash that forces deletion of 'stuck' items; I revealed the hidden files / folders in my own User folder (using cmd-shift-dot) and found the 'bin' folder with the unwanted user inside - I opened that and found the culprit 'voice trigger' folder. I tried setting the permissions on that to Admin read & write but even that didn't work; I tried booting into safe mode and seeing if I could delete from there but that didn't work either. Nothing seemed to work.
The solution
So, here's what I did. I have a bootable clone of my hard drive on an external drive as insurance (made with Carbon Copy Cloner). I plugged that drive in and set it as the startup disk (System preferences > Startup disk) and rebooted. Once the mac had booted off the external drive, you can see the internal MacintoshHD drive in the left panel of the finder window in the usual place. I opened the MacintoshHD and navigated to my own User folder and use cmd-shift-dot to display the hidden files and folders therein. I found the .Trash folder and inside it was the rogue unwanted user folder I had been trying to delete. Only this time, as I'd booted off of the external drive, the unwanted user folder wasn't in use by anything so I was able to drag it to the trash (ie the trash can in the dock) - and was able to empty the trash in the normal way.
I switched the start up drive back to the MacintoshHD and rebooted and voila - the rogue unwanted user folder had gone from the trash.
Hope this helps someone.
Reboot to Recovery:
- Restart holding command ⌘ + R
- Open terminal from utilities menu
- Type
csrutil disable
then reboot - Empty trash
- Reboot to recovery holding command ⌘ + R
- Open terminal from utilities menu
- Type
csrutil enable
then reboot - Problem may be fixed
Don't attempt to delete ~/.Trash
! Delete the contents of it. If you don't have any dot files you can just rm -rf ~/.Trash/*
. If you do you can rm -rf ~/.Trash/{.[^.],}*
.