trashcan under GNU/Linux with 'libtrash' mini-HowTo |
Sebastian Utz seut@tunemedia.de
last changes
Revision 1.2 2003/01/25 09:06:51 jonen + updated
All stuff here is mainly copied from the libtrash doc.
libtrash is a shared library which, when preloaded, implements a trash can under GNU/Linux. This way, your mistakes (at least those of the "rm -rf dir /" class :-)) will no longer cause the loss of a week's work or your system's binaries.
apt-get install libtrash
or for those of you that aren't running Debian GNU/Linux:
wget http://www.m-arriaga.net/software/libtrash/libtrash-latest.tgz tar xzf libtrash-latest.tgz cd libtrash-1.7/
edit Makefile for common settings
make install (as root)
export LD_PRELOAD=/usr/lib/libtrash/libtrash.so rm -r <some_test_file>
Include this in your ~/.bash_profile(or for system-wide usage in /etc/profile) to enable libtrash every time you log in (or otherwise start a login shell)
#-------------- snip --------------------------- LIBTRASH=/usr/lib/libtrash/libtrash.so
LIBTRASH_dest=$LIBTRASH if test -L $LIBTRASH ; then LIBTRASH_dest="$(dirname $LIBTRASH)/$(ls -l "$LIBTRASH" | \ sed -e 's/^.\+ -> //')" fi
if test x${LD_PRELOAD+set} = x -a -f "$LIBTRASH_dest" ; then LD_PRELOAD="$LIBTRASH" export LD_PRELOAD if test x$0 = x-bash ; then exec bash ${1+"$@"} else exec $0 ${1+"$@"} fi fi #-------------- end snip ---------------------------
- READ /etc/libtrash.conf !! - overwrite default values by setting up a ~/.libtrash for each user:
# sample ~/.libtrash: #-------------- snip --------------------------- GLOBAL_PROTECTION = YES INTERCEPT_FOPEN = YES INTERCEPT_FREOPEN = YES INTERCEPT_OPEN = YES IGNORE_HIDDEN = NO IGNORE_EXTENSIONS= o;exe #-------------- end snip ---------------------------
- gunzip & copy '/usr/share/doc/libtrash/examples/cleanTrash/ct2.pl.gz' to '/usr/local/bin/cleanTrash' e.g:
'zcat /usr/share/doc/libtrash/examples/cleanTrash/ct2.pl.gz > /usr/local/bin/cleanTrash'
- edit '/usr/local/bin/cleanTrash' for local configuration
- crontab -e (as root) - insert: 3,13,23,33,43,53 * * * * root /usr/local/bin/cleanTrash
READ /etc/libtrash.conf !! If libtrash.so is global enabled via /etc/profile, a DEFAULT or WRONG ~/.libtrash configuration would causes gdm, root writes(if root writes are also protected by lintrash), kde etc. stops working !!
solution to disable libtrash in enviroment immediately: - export LD_PRELOAD=""
to get a login shell, start XTerm with '-ls' (~/.profile will not be executed if not)
http://www.m-arriaga.net/software/libtrash/
trashcan under GNU/Linux with 'libtrash' mini-HowTo |