Best way to force empty trash?

Joined
May 9, 2010
Messages
8
Reaction score
0
Points
1
I have a ton of files stuck in my trash bin, and I can't get it to empty. Several files are from a bunch of old backups that I no longer needed.

I tried an app called TrashIt!, but it's not working for me.

Are there better suggestions out there to get this emptied.

I am running OSX 10.6.8

Thanks
Mark
 

vansmith

Senior Member
Joined
Oct 19, 2008
Messages
19,924
Reaction score
559
Points
113
Location
Queensland
Your Mac's Specs
Mini (2014, 2018, 2020), MBA (2020), iPad Pro (2018), iPhone 13 Pro Max, Watch (S6)
Open up Terminal and enter the following:
Code:
sudo rm -rf ~/.Trash/*
Enter your password and voila.
 

vansmith

Senior Member
Joined
Oct 19, 2008
Messages
19,924
Reaction score
559
Points
113
Location
Queensland
Your Mac's Specs
Mini (2014, 2018, 2020), MBA (2020), iPad Pro (2018), iPhone 13 Pro Max, Watch (S6)
Nope. Execute that and your Trash will be empty.
 
OP
S
Joined
May 9, 2010
Messages
8
Reaction score
0
Points
1
It's still not working. I enter the code hit enter, enter my password hit enter. Go to empty trash and I still get the error code and the trash won't empty.
 
Joined
May 19, 2009
Messages
8,428
Reaction score
295
Points
83
Location
Waiting for a mate . . .
Your Mac's Specs
21" iMac 2.9Ghz 16GB RAM - 10.11.3, iPhone6s & iPad Air 2 - iOS 9.2.1, ATV 4Th Gen tvOS, ATV3
There is something not right here then, bc the Terminal command Vansmith gave you should of emptied the trash without you having to go there to empty it.

Try this Shift-Command-Option-Delete as a 4 key combo after opening the trash window.

Are you sure the files you are trying to trash don't have ANY system files in there what so ever ?? If you have one of those it might be stopping you emptying it.
 

vansmith

Senior Member
Joined
Oct 19, 2008
Messages
19,924
Reaction score
559
Points
113
Location
Queensland
Your Mac's Specs
Mini (2014, 2018, 2020), MBA (2020), iPad Pro (2018), iPhone 13 Pro Max, Watch (S6)
It's still not working. I enter the code hit enter, enter my password hit enter. Go to empty trash and I still get the error code and the trash won't empty.
That should have emptied the Trash. That command elevates the privileges and forces removal.

What is the exact error message you're getting?
 
Joined
May 19, 2009
Messages
8,428
Reaction score
295
Points
83
Location
Waiting for a mate . . .
Your Mac's Specs
21" iMac 2.9Ghz 16GB RAM - 10.11.3, iPhone6s & iPad Air 2 - iOS 9.2.1, ATV 4Th Gen tvOS, ATV3
i found this

Drag the file from your Trash bin to the Desktop.
Launch a Terminal Go > Utilities > Terminal and type the following into the terminal window leaving a space after f:

Code:
cd ~/.Trash && sudo rm -rf



Drag the file from your Desktop to the terminal window and then press Enter
Enter your password when prompted and press Enter
 

vansmith

Senior Member
Joined
Oct 19, 2008
Messages
19,924
Reaction score
559
Points
113
Location
Queensland
Your Mac's Specs
Mini (2014, 2018, 2020), MBA (2020), iPad Pro (2018), iPhone 13 Pro Max, Watch (S6)
That command is essentially the same thing. ;)

You don't need to "cd" to ~/.Trash if you're going to do the "sudo rm -rf" and drag file to Terminal method.

OP: Where did you delete these files from?
 
Joined
May 19, 2009
Messages
8,428
Reaction score
295
Points
83
Location
Waiting for a mate . . .
Your Mac's Specs
21" iMac 2.9Ghz 16GB RAM - 10.11.3, iPhone6s & iPad Air 2 - iOS 9.2.1, ATV 4Th Gen tvOS, ATV3
That command is essentially the same thing. ;)

You don't need to "cd" to ~/.Trash if you're going to do the "sudo rm -rf" and drag file to Terminal method.

Yea well I'm not the resident nerd/geek around here ;) so didn't know the difference. I thought it different as it asked to drag it to the desktop 1st. Im glad you pulled me up on that one vansmith

Cheers
 

vansmith

Senior Member
Joined
Oct 19, 2008
Messages
19,924
Reaction score
559
Points
113
Location
Queensland
Your Mac's Specs
Mini (2014, 2018, 2020), MBA (2020), iPad Pro (2018), iPhone 13 Pro Max, Watch (S6)
Yea well I'm not the resident nerd/geek around here ;) so didn't know the difference. I thought it different as it asked to drag it to the desktop 1st. Im glad you pulled me up on that one vansmith

Cheers
Haha, it's what I do best my good man. :)

If you're interested, your command set the Terminal prompt to work out of the .Trash directory (cd = change directory). The sudo bit executes the command with elevated privileges, rm removes it and -rf tells "rm" to remove the files recursively and to force it. Your friendly Unix tip of the day.
 
Joined
May 19, 2009
Messages
8,428
Reaction score
295
Points
83
Location
Waiting for a mate . . .
Your Mac's Specs
21" iMac 2.9Ghz 16GB RAM - 10.11.3, iPhone6s & iPad Air 2 - iOS 9.2.1, ATV 4Th Gen tvOS, ATV3
Haha, it's what I do best my good man. :)

If you're interested, your command set the Terminal prompt to work out of the .Trash directory (cd = change directory). The sudo bit executes the command with elevated privileges, rm removes it and -rf tells "rm" to remove the files recursively and to force it. Your friendly Unix tip of the day.

Ill be expecting them to continue to Professor . . . . *bows*

But in all sincerity i appreciate the lesson ;)
 
Joined
Mar 17, 2008
Messages
6,879
Reaction score
191
Points
63
Location
Tucson, AZ
Your Mac's Specs
Way... way too many specs to list.
Keep in mind, this won't delete files that are in use. You can automate that as well, but as with any automation, you need to make sure you're doing what you want. lsof (list open files) can help you show which files are in use. For instance...


Code:
## find all files in trash that are in use, and the using program ID
for i in $(lsof |grep ".Trash" |awk '{print $2}')
      do
## Kill all pid's using files in trash
      kill $i
## now use Van's command to empty
sudo rm -rf ~/.Trash/*
done

If you wanted to unconditionally kill the pids, you'd use a -9 switch.
 
Joined
Feb 12, 2012
Messages
1
Reaction score
0
Points
1
Worked for me

This worked for me.

This was so much quicker than using the "secure empty" with Trash. If I am comfortable with the command line, why wouldn't I want to empty trash all the time like this?
 
Joined
May 19, 2009
Messages
8,428
Reaction score
295
Points
83
Location
Waiting for a mate . . .
Your Mac's Specs
21" iMac 2.9Ghz 16GB RAM - 10.11.3, iPhone6s & iPad Air 2 - iOS 9.2.1, ATV 4Th Gen tvOS, ATV3
If I am comfortable with the command line, why wouldn't I want to empty trash all the time like this?
Welcome

I suppose if your a power user and have Terminal open most of the time it is a viable option. But if your a power user then why not just empty trash.
I have a great little App that IMHO has surpassed what QuickSilver ever did but with Alfred in 2 quick keyboard commands my trash is emptied.
Why wouldn't i use that to empty my trash if I'm comfortable with the command line ??
 
Joined
Feb 24, 2006
Messages
73
Reaction score
0
Points
6
Your Mac's Specs
G4 + Mac Pro 8-core 6Gb
I wanted to remove old time machine backups, which are a waste of space. Re backing up a few bytes seems to be the tidiest way to do it, but my oldest backup can't be 'put back' - I like that function - I thought you'd have to specify where to put it. There's no space. It's just an alias. It's big in the bin. I need to empty the trash. It's what I do before any backups...
 
Joined
Oct 30, 2010
Messages
273
Reaction score
0
Points
16
Location
Southern Illinois
Your Mac's Specs
MBP 15" I7 first one and loving it.
I wrote a little file to empty the trash. Seems a bit silly but seems to work good for me. Created a file called etrash. Added /Users/xxxxxx to PATH in /etc. I have to enter sudo password when it runs. But I just type the name and the file runs.

#!/bin/bash
#script to empty the trash folder

clear
echo "I'm going to empty the Trash Folder "
echo ""
echo ""
sudo rm -Rfv ~/.Trash/*
echo ""
echo ""
echo "All done"
echo ""
echo "Later Dude"
echo ""
echo ""
echo ""
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top