Trash can or Recycle bin in Linux Desktop (managed from console)
Linux Desktops, at least Gnome and KDE has a trash can, where your deleted files go, (only when deleted from a Desktop utility).
Now if you want to manage it from the console, you can, first we need to know that the trash can is only another folder in the File system structure and it is located at:
$HOME/.Trash
so you can send files to Trash just moving them to there, as an example, lets suppose you have a file in your home called balance.ods and want to move it to the trash can.
mv $HOME/balance.ods $HOME/.Trash/
Whenever you may want to recover it, just move it to its original location or to any other you prefer, just like this:
mv $HOME/.Trash/balance.ods $HOME/
and you are done, if you want to purge your trash can, just enter.
rm -rf $HOME/.Trash/*
BE AWARE: This action can not be undone!!, so use with care
you can even create a script to use instead of rm in your console, the easiest one is this:
#!/bin/sh mv $1 ~/.Trash
If somebody can think into a better one, please share with us, hope you may find this info useful.
Trackback URL for this post:
If you like this article, subscribe to our full rss
Please post your question in our forum and use comments only to leave your comments about the article, thanks.













A more correct "rm"
A more correct "rm" replacement would be:
#!/bin/sh
mv $* ~/.Trash
which would handle multiple arguments.
Hey! thanks Guillermo Garron
Hey! thanks
Guillermo Garron
You might want to try rmw,
You might want to try rmw, ReMove to Waste, a little bash script I came up with.
http://sourceforge.net/projects/rmw/
Not mine, but another utility for removing (or not removing) files is safe-rm
Tool intended to prevent the accidental deletion of important files by replacing /bin/rm with a wrapper, which checks the given arguments against a configurable blacklist of files and directories that should never be removed.
Users who attempt to delete one of these protected files or directories will not be able to do so and will be shown a warning message instead.
Protected paths can be set both at the site and user levels.
Post new comment