4

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.

8
  • 1
    Iā€™m thinking you have user files in your trash? might you edit what the count of files is in ls -laR ~/.Trash | wc -l and if so, this might be as simple as changing the remove to end in ~/.Trash/.?* rather than deleting your trash folder and instead targeting the contents of that directory for removal. – bmike Jul 12 '20 at 13:39
  • @bmike always getting Operation not permitted back. – christophriepe Jul 12 '20 at 13:41
  • Have you tried restarting and emptying the Trash again? A restart may unlock some items. – jaume Jul 12 '20 at 13:56
  • @jaume Yes I did that. But did not change anything – christophriepe Jul 12 '20 at 14:31
  • Are the profiles still in System Preferences where you could delete them? macOS probably has some sort of file lock on them because it thinks they are still in use. Deleting them there (if possible) might help... – Steve Chambers Jul 12 '20 at 15:27
2

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.

1

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/{.[^.],}*.

1
  • Why would it be a bad idea to rm -r ~/.Trash? – nohillside Dec 26 '20 at 9:39
1

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
1
  • Once you've booted to Recovery you might even be able to delete the files directly (without disabling SIP first). – nohillside Dec 26 '20 at 9:39
0

Your Mac is in a state where other user access control prevents you from getting details from your trash.

Follow this, especially the recovery portion.

1
  • I followed all the instructions and started my Mac in Safe Mode. However, the files are still in use and can't be deleted. Any other idea? – christophriepe Jul 13 '20 at 16:16

Not the answer you're looking for? Browse other questions tagged .