Empty User X's Trash while Logged in as User Y

I’ve come into an interesting predicament. I can view the contents of another user’s trash while logged in as another user, but I am unable to delete the contents, i.e. a quick “sudo rm -rf /Users/foo/.Trash/*” won’t work. The command executes just fine, but the contents of the .Trash folder remain untouched.

How would I empty said trash while logged in as another user – if it is even possible? The reason I ask is that students here on campus often throw away large files (photoshop, illustrator, maya, etc.) but don’t empty the trash. This takes up valuable HD space. So I started toying with the idea of writing a quick maintenance script that I could jet over via Remote Desktop to empty the trash on all the accounts.

The script for navigating user account is trivial, it’s the script for actually emptying the trash that’s gotten me stuck.

Alternatively, can I simply set a trash quota like on Windows? Say, a mximum trash size of 1 GB?

Much Thanks,

On my machine the hard disk has 4 partions, one of which has 2 users. Every volume and every user has a separate .Trash folder, so to “trash” another users .trash folder, you’ll have to find them all.

Are you sure? I did a quick find -E /Users/foo/ "testing123.txt" | grep "testing123.txt" and it only came up in one location.

Regardless, even when I “deleted” the contents of the .Trash folder, nothing changed inside of it.

On my root volume, I find three with File Buddy: one at /Users/myShortName, one at /private/var/root, and one in /Users/Ghost (my other account). In File Buddy, I can see the “other” trash, and it’s contents, which do not show up in mine. I can remove either of them.

Having said that, sudo find .trash finds only one, and that one still contains something I thought gone when I emptied the trash and with File Buddy, I can move it back to the desktop, so it really exists.

Ah. I figured it out. Just needed to brainstorm with someone, thanks. It turns out that I can’t delete the contents in the .Trash folders, however, I can delete the .Trash folder it self, which, incidently, deletes its contents as well. :slight_smile: A bit odd, but it works. So, now I have a script to get a list of all the users, then run an “rm -rf /Users/currentUser/.Trash/” shell script on each of the users and voila: No more un-emptied trash taking up HD space.


And you aren’t going to post your script???