Go2Linux | Linux Operating System

A site dedicated to: Linux Operating System

Trash can or Recycle bin in Linux Desktop (managed from console)

Date: 2008-04-04 00:00:00 -0400

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.

If you liked this article please share it.

powered by TinyLetter

If you want to contact me in any other way, please use the contact page.