Use rm to empty Trash?

Joined
Sep 25, 2015
Messages
396
Reaction score
10
Sometimes, you get things "stuck" in the trash that don't want to empty. I used to be able to do "rm -r .Trash", and it would work fine.
Now, even when I am root, I get

mycomputer$ rm -r .Trash
rm: .Trash: Operation not permitted

Huh? How does one empty the Trash from the command line? If root can't do it, who can?
 
Joined
Feb 14, 2021
Messages
988
Reaction score
131
Sometimes, you get things "stuck" in the trash that don't want to empty. I used to be able to do "rm -r .Trash", and it would work fine.
Now, even when I am root, I get

mycomputer$ rm -r .Trash
rm: .Trash: Operation not permitted

Huh? How does one empty the Trash from the command line? If root can't do it, who can?
Dan, I haven’t had to do it lately but I always used Onyx to perform this operation.
 
Joined
Sep 25, 2015
Messages
396
Reaction score
10
Well, I could use Onyx, but it takes a lot more keystrokes to get there. What function in Onyx does this? Onyx is a nice tool, but it doesn't really make it that clear what exactly it is doing. Is Maintenance-Misc. Options-Trash the task I'd need to run?
 
Joined
Feb 14, 2021
Messages
988
Reaction score
131
Well, I could use Onyx, but it takes a lot more keystrokes to get there. What function in Onyx does this? Onyx is a nice tool, but it doesn't really make it that clear what exactly it is doing. Is Maintenance-Misc. Options-Trash the task I'd need to run?
In Onyx, simply go to File -> Force Empty Trash. You will be taken to the appropriate window.

Over the years, I have developed a high level of confidence in Onyx. Their versions are specific to every macOS version. So just to simplify troubleshooting and maintenance tasks that I don’t wish to learn for command line execution, it’s a great solution. Of course, for Terminal commands that I often invoke, direct entry is still the simplest way to go.
 
Joined
Sep 25, 2015
Messages
396
Reaction score
10
Thank you. That's a lot easier than I thought. That actually goes to Onyx: Files-Delete-Empty Trash.

My question still stands, however, as to why the terminal commands don't work. In Mountain Lion, they used to work fine. Now, Onyx isn't asking to be root to get this done, but it does ask for my user password. So how come rm -r .Trash won't work for me like it used to? Now, Onyx *says* that it is acting on /Users/me/.Trash/, but when I do it manually, it doesn't work. What is Onyx doing??

Now, the OS may not want me actually deleting the .Trash folder, which I guess is what it thinks I'm trying to do. But if I cd to that folder, and then do an rm *, I'm still denied.
 
Joined
Feb 14, 2021
Messages
988
Reaction score
131
Thank you. That's a lot easier than I thought. That actually goes to Onyx: Files-Delete-Empty Trash.

My question still stands, however, as to why the terminal commands don't work. In Mountain Lion, they used to work fine. Now, Onyx isn't asking to be root to get this done, but it does ask for my user password. So how come rm -r .Trash won't work for me like it used to? Now, Onyx *says* that it is acting on /Users/me/.Trash/, but when I do it manually, it doesn't work. What is Onyx doing??

Now, the OS may not want me actually deleting the .Trash folder, which I guess is what it thinks I'm trying to do. But if I cd to that folder, and then do an rm *, I'm still denied.
Just tried it myself, and even sudo doesn’t work. Perhaps turning on root user and doing it from there will work.

I can’t recall the last time I used this command, but apparently the newer macOSes have changed the rules. Man doesn’t show any difference, though. When I get the chance, I will boot into my oldest operating system, Mojave, and see if it behaves any differently.
 
Joined
Sep 25, 2015
Messages
396
Reaction score
10
As I said, I don't think root user has much to do with it, since Onyx isn't asking for your root password in order to do it. Now, Onyx is just a front-end for terminal commands, so there must be a way to do it via terminal commands.
 
Joined
Jan 25, 2017
Messages
1,266
Reaction score
100
I tried this on a couple of machines. On a macbook air running 11.6.3 I get the error message but on an imac running 11.6.2 it works as it should.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top