Talkin’ Trash in Linux

i-38f5e4d16e1655cf3be0bdf51c5bf72d-this_parrot_is_clobbered_linux.jpg

This file is clobbered…
Linux and related operating systems are different from, say Windows, in many ways. One is this: When you “delete” a file in, say Windows, you are asked to confirm the operation, then the file is moved to the trash folder, not deleted. In Linux, when you “delete” (remove) a file, it is clobbered. Gone. It is a defunct entity.

This might seem scary because what if you didn’t want to delete the file, or whatever? Well, there are a lot of reasons that the “delete it without asking” philosophy is better than the “ask this dumb question again and again” philosophy. We can fight about this if you want. But I’ll tell you this: When you switch to Linux and operate that way for a while, then go back to an operating system that is always asking you “Are you sure you want to do this thing and are you sure you want to do that thing” every freakin’ time you want to do something, you realize the value of a system that simply does what it is told. Let me elaborate further as to why Linux is better than Windows in this regard:

1) The total amount of time you spend saying “OK” to every single stupid question is much greater than the benefit of the occasional “oops” moment;

2) Chances are, if you did not really want to delete the file, this is not because you pressed the “delete” button in a passing moment of derangement. Chance are, what happened is something went wrong and you are not totally aware of that. For instance, Windows threw a widow in front of your mouse while you were doing something else, or some other stupid thing happened. When this appears on your screen:


Do you bla bla bla

OK Cancel


you are going to hit “OK” anyway. And the file will be deleted anyway.

3) Despite what I’ve said above, most/many Linux desktop environments, such as gnome, have a “trash can” … so even though you are not being asked again and again “do you really want to delete this,” when you do delete a file with the GUI file management software, it goes into the trash directory and not the blottosphere.

4) When you are working on the command line you are really working with the equivalent of an interpreted computer language. You do not want feedback from your commands in almost all cases. If a command routinely gives you feedback, especially the kind where you have to answer a stupid question, how do you string it together with other commands into a script?

5) When you are working on the command line (and often in other contexts) on a Linux computer, you are actually working in a world that is different from WindowsWorld or even MacWorld. This is why Linux is not for everyone. You are driving a stick, not an automatic. You are stretching your own canvas, not buying some dumb movie poster to hang on your wall. You are loading your own cartridges. You are taking personal responsibility for your own data and processes.

So when you consider removing a file, you must also consider at that time if this is something that can happen with no backup at all or something that should never happen without backup, or somewhere in between. You decide, and you do it that way. You chose between converting FileA to FileB or transforming FileA in place with the old version eliminated.

Having a system that constantly assumes otherwise is obnoxious and inappropriate. It would be like driving down an icy curvy highway, seeing movement … maybe a deer …. off ahead and to the side, and down shifting, and then having the transmission override your decision or stop to ask you if you really mean to do that, and you fail to maintain control of the vehicle, the deer runs out in front of you and you can’t safely swerve and wack!!!! Bambi is dead!!! Killing Bambi with your operating system is not acceptable.

Having said all that, wouldn’t it be nice to have Linux “remove” your command line deleted files to the trash can? Well, it depends.

There is a KDE based command (it probably works in gnome too) for moving stuff to the trash can and later manipulating the trash can here. However, in my humble opinion it is flawed. I could be wrong (comments welcome). For one thing, the commands that is requires are different from one another (ImageMagick style). To throw something out you invoke ‘trash’ but to list what is in the trash can you invoke ‘list-trash’.

I would prefer to see all the commands be “trash” with switches, and/or to have all the commands start with ‘trash’ … so you could have:

trash – copies a file to the trash can
trash-list – lists the contents of the trash can
trash-restore foo – restores foo

and so on.

But there may be an even better way to do all of this. With simple knowledge. Know that, for instance, in gnome (and probably other desktops) the “trash” is located in a directory inside your home directory, here:

.Trash

The dot at the beginning makes the folder invisible, but it is there, in your home directory. Go to your home directory in a terminal and type in “cd .Trash” followed by “ls” and you’ll see all of your dirty laundry right there.

So when you really don’t want to throw stuff out, throw it in the trashcan instead. For instance, copy it to the trash, then delete it in place.

The cited utility for a command line trash may be useful, but I would strongly urge you to NOT do one thing recommended on their web site: To create an alias so that “rm” invokes this utility. rm is the “remove” command (delete) in Linux. If the standard delete command becomes the ‘move to trash’ facility, and you write a script that creates and then clobbers a zillion files, you may have problems. The reason for having a trash can is so that you, the user, can go rooting around in it for stuff you accidentally threw away. You don’t want the entire waste stream of your computer system dumping everything in there. That would be like hooking your sewer outlet to the trash can in your kitchen. You would not want to go in there looking for the coupon you accidentally threw out with the junk mail…

Comments

  1. #1 Stephanie Z
    June 17, 2008

    Okay, but I’m still worried about that widow. Is she one of the crazy cat ladies, and if she is, what happens to my mouse? Oh, wait. I use a trackball. Mice are for snakes. Still, someone should talk to Microsoft about throwing people around like that.

    Sorry, it wanted desperately to be said. Blame sleep deprivation. I’ll go back to ignoring typos now.

  2. #2 Eamon Knight
    June 17, 2008

    You are driving a stick, not an automatic. You are stretching your own canvas, not buying some dumb movie poster to hang on your wall. You are loading your own cartridges.

    Help, I’m drowning in metaphors! (Oops, I think I just made a metametaphor)

    But yeah, Windbloze is a pain. My current peeve: When selecting text in Word and Outlook, it seems to insist on grabbing a few characters (or even whole lines!) extra. I’m tired of the “I know what you really meant” attitude.

  3. #3 StuV
    June 17, 2008

    1. So turn them off.
    2. Right-click Recycle Bin, Properties, un-check “Display Delete Confirmation Dialog”.
    3. Ahem.
    4. Del /Q, Copy /Y. Any others you need help with?
    5. Really. So what is the primary, philosophical difference on the Linux command line? You wax poetic, but give us something to chew here.

    Eamon: Open Word. Tools, Options, Edit, uncheck “Use smart paragraph selection” and “When selecting, automatically select entire word”. Works for Outlook as well (since you probably have Word as your editor).

    Tsk tsk tsk, guys.

  4. #4 Stephanie Z
    June 17, 2008

    Hmm, Stu, I’m torn. I mean, it’s still deeply annoying when Windows users get all smug about their systems, but at the same time, unless you know exactly what you’re looking for, it really is quite the accomplishment to have found something useful.

  5. #5 StuV
    June 17, 2008

    For the record, there are plenty of things in Windows to pick on… better ones than things permanently fixable with 5 mouseclicks.

    I think.

    Or do I?

  6. #6 TimJ
    June 17, 2008

    Well, actually using an alias isn’t that bad if in your scripts you use \rm or the full path like /bin/rm (which is probably the better idea, for safety. I always use full path names for shell commands in scripts). Of course, if you like the extra confirmation as in Windows, you can always use /bin/rm -i . Yet another option is to write your own script that copies stuff to a trash can (add security features and options to taste). It should probably go without saying that one should be doing backups (or replication, such as drbd) anyway :) .

  7. #7 Gray Gaffer
    June 17, 2008

    Yes, mostly.

    Windbloat: 5 mouse clicks – if you know where to put them. I had to figure put where to turn off the numbered list creation when I needed a list with non-monotonic numbers. Took a lot more than 5 clicks since that particular feature switch is not located in the same place as the selection behavior. Not even the same dialog, not even the same menu.

    stick shift: OSX has Free BSD under the hood, via Terminal or iTerm (my preference). All the same commands and powers and caveats apply as to Linux. Windbloat also has the ‘command window’, but do not be fooled, the batch language is far inferior to *nix / BSD.

    Throwing widows under the moose has to be the most unfriendly behavior. Especially to touch-typing-challenged like myself who have to watch our fingers when typing and not the screen. At least OSX apps typically support bouncing or tagging their icon in the dock as a way of requiring attention, and do not usurp input focus.

  8. #8 Mr. Upright
    June 17, 2008

    I have always hated the confirmation requests and other delete protections. That’s why I developed the habit, years ago on Unix systems, to use “rm -rf”. Force that delete and recurse throught the subdirectories. Now that’s nuking your files!

  9. #9 John S. Wilkins
    June 17, 2008

    How does Linux’ behaviour differ from the MacOSX? Same things apply – if you delete from the CLI, it’s gone, baby, gone. What puts files in the Trash is Finder, which is a GUI application. Once you empty that Trash, it’s gone, baby, gone. And you can write your own scripts for the *nix engine under the hood, if you want to ride stick.

  10. #10 Greg Laden
    June 18, 2008

    John: In this regard and many others, they are the same operating system. Most code that will run ‘under the hood’ in Mac OS X should run in Linux and visa versa, as long as “under the hood” means “under aqua/carbon/gnome/kde/quartz/etc”

    StuV: Sorry, that is totally un-OK. If you make a list of all the tweaking you have to do to make a default windows/office installation not be totaly sucky it would take five or six days, and have to be redone everytime the system either reset itself mysteriously or totally crashed and requried a reinstall…. so, like, twice a month at least. I’d rather have an operating system that just works.

    Linux. It just works.

    Oh wait, sorry, gotta run. There are unused icons on my desktop and I need to clean them.

  11. #11 cfeagans
    June 18, 2008

    It reminds me of the old OS joke:

    Three guys find themselves at the urinals of a restroom. The first guy finishes and heads to the sink and uses paper towel after paper towel to dry off. To the other two he says, “as a loyal Windows user, I’m accustomed to taking advantage of every available resource to get the job done.”

    The second guy washes up and uses the air dryer, stating: “I’m a Mac user and I always expect to conserve resources -besides, the air dryer is more efficient.”

    The third guy just zips up and heads for the door, saying over his shoulder, “Linux users don’t piss on their hands.”

  12. #12 synapse
    June 18, 2008

    Our lab decided that the default of “rm” should be to ask for confirmation after one guy accidentally lost two days’ worth of rare data (after being up for two days straight to collect said data). (The incident caused other problems for the lab, too, since he locked the computer to prevent the data from being overwritten but neglected to tell the other users.) So now we all type “rm -f” without thinking…

  13. #13 Greg Laden
    June 18, 2008

    “Linux users don’t piss on their hands.”

    Tee-Shirt! tee-shirt!!!!

    Synapse: I would think a better solution would be to leave rm alone and use ‘delete’ instead, whereby delete by default uses rm -f. Otherwise every script you import that makes temp files to clean up internally will fail or get hinkey in some way. Wouldn’t it? (Well, not the idiot proof ones, but any that, say I wrote)

  14. #14 StuV
    June 18, 2008

    So Windows sucks because you don’t like the UI defaults.

    Oh, and of course, you do NO customizing on Linux.

    Greg, I don’t know WHAT you do to your Windows installations, but I have a 9 month, 2 year, 3 year and 5 year installation at home without issues.

  15. #15 Chris
    June 18, 2008

    So when you really don’t want to throw stuff out, throw it in the trashcan instead. For instance, copy it to the trash, then delete it in place.

    It’s much more efficient just to move the files to the trash. You don’t waste all those cycles and disk IO copying the file.

    Not that I use the trash anyway…

  16. #16 MH
    June 18, 2008

    As has been pointed out, if you don’t like confirmations in XP, switch them off. Simple.

    I do prefer the bin in Ubuntu, though. I like being able to restore a deleted file to anywhere I want, and to explore folders in the bin.

    I made the switch to Linux a few months ago, and I’m generally loving it. That said, I don’t think XP is that bad. Vista, however… {shakes head slowly}

  17. #17 Christophe Thill
    June 19, 2008

    Also, there are unerase utilities for Linux, at least for ext3 filesystems. A bit complicated to use, perhaps. But we’re talking command line users, aren’t we? If you prefer a nice graphical interface, there’s always a way to have a trashcan (at least the graphical interfaces Gnome and KDE have it).

  18. #18 Greg Laden
    June 19, 2008

    I just want to be clear on two things. First, yes, some windows installs last. I have one sitting here that has not failed for three y ears. It does not doo much and has had no service pack updates and is not needed for antything other than games and iTunes, so of course it just sits there.

    Second, it is not UI defaults that can be changed that bother me with Windows, although yes, they do all suck. It is many things, but included are the fact that Windows IS a UI, and a poorly designed one, and little more. Under those conditions, why would I ever want to use it? Furthermore, many of the UI behaviors are not changeable defaults. The fact that some are changeable is really not relevant.

    Of course, I’m the guy that thought Windows 2000 was the peak of Windows. XP to me is everyone else’s Vista.

  19. #19 qbsmd
    June 19, 2008

    “Of course, I’m the guy that thought Windows 2000 was the peak of Windows. XP to me is everyone else’s Vista.”

    I’ve said that before. Now, I mostly use XP with all the settings running as close to windows 2000 as possible (themes disabled, set to run at best performance). It wouldn’t be so bad if windows had a configuration file I could copy from computer to computer instead of spending 10 minutes changing all the settings on each computer I use.
    The thing about operating systems that bothers me most is when I am typing, and some other window comes up and blocks whatever I was doing. I’m pretty sure I’ve had Linux do that too.

  20. #20 Greg Laden
    June 19, 2008

    The thing about operating systems that bothers me most is when I am typing, and some other window comes up and blocks whatever I was doing. I’m pretty sure I’ve had Linux do that too.

    It can happen in gnome, but it is very very rare. This is the biggest and most important difference, by far, of the GUI.

    A close second is what the GUI thinks is a process. When you switch using Alt Tab for instance, what happens in Windows vs. Linux are entirely different.