1 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
2 |
<html xmlns="http://www.w3.org/1999/xhtml"> |
3 |
<head> |
4 |
<title>trashcan under GNU/Linux with 'libtrash' mini-HowTo</title> |
5 |
<link rev="made" href="mailto:root@localhost" /> |
6 |
</head> |
7 |
|
8 |
<body style="background-color: white"> |
9 |
|
10 |
<p><a name="__index__"></a></p> |
11 |
<!-- INDEX BEGIN --> |
12 |
|
13 |
<ul> |
14 |
|
15 |
<ul> |
16 |
|
17 |
<li><a href="#implements_a_trash_can_under_gnu/linux_with_'libtrash'">Implements a ``trash can'' under GNU/Linux with 'libtrash'</a></li> |
18 |
<ul> |
19 |
|
20 |
<li><a href="#description">Description</a></li> |
21 |
<ul> |
22 |
|
23 |
<li><a href="#install_libtrash">install libtrash</a></li> |
24 |
<li><a href="#test">test</a></li> |
25 |
<li><a href="#enable_libtrash_at_login">enable libtrash at login</a></li> |
26 |
<li><a href="#create_user_specify_config">create user specify config</a></li> |
27 |
<li><a href="#use_'cleantrash'_for_cleaning_trash_via_cronjob">use 'cleanTrash' for cleaning Trash via cronjob</a></li> |
28 |
<ul> |
29 |
|
30 |
<li><a href="#insert_cronjob_for_root">insert cronjob for root</a></li> |
31 |
</ul> |
32 |
|
33 |
</ul> |
34 |
|
35 |
<li><a href="#important_notes">Important Notes</a></li> |
36 |
<li><a href="#resources">Resources</a></li> |
37 |
<li><a href="#authors">Authors</a></li> |
38 |
<li><a href="#last_changes">Last changes</a></li> |
39 |
</ul> |
40 |
|
41 |
</ul> |
42 |
|
43 |
</ul> |
44 |
<!-- INDEX END --> |
45 |
|
46 |
<hr /> |
47 |
<p> |
48 |
</p> |
49 |
<h2><a name="implements_a_trash_can_under_gnu/linux_with_'libtrash'">Implements a ``trash can'' under GNU/Linux with 'libtrash'</a></h2> |
50 |
<p> |
51 |
</p> |
52 |
<h3><a name="description">Description</a></h3> |
53 |
<pre> |
54 |
All stuff here is mainly copied from the libtrash doc.</pre> |
55 |
<pre> |
56 |
libtrash is a shared library which, when preloaded, implements a trash can under GNU/Linux. |
57 |
This way, your mistakes (at least those of the "rm -rf dir /" class :-)) will no longer cause |
58 |
the loss of a week's work or your system's binaries.</pre> |
59 |
<p> |
60 |
</p> |
61 |
<h4><a name="install_libtrash">install libtrash</a></h4> |
62 |
<pre> |
63 |
apt-get install libtrash</pre> |
64 |
<pre> |
65 |
or for those of you that aren't running Debian GNU/Linux: |
66 |
|
67 |
wget <a href="http://www.m-arriaga.net/software/libtrash/libtrash-latest.tgz">http://www.m-arriaga.net/software/libtrash/libtrash-latest.tgz</a> |
68 |
tar xzf libtrash-latest.tgz |
69 |
cd libtrash-1.7/ |
70 |
|
71 |
edit Makefile for common settings |
72 |
|
73 |
make install (as root)</pre> |
74 |
<p> |
75 |
</p> |
76 |
<h4><a name="test">test</a></h4> |
77 |
<pre> |
78 |
export LD_PRELOAD=/usr/lib/libtrash/libtrash.so |
79 |
rm -r <some_test_file></pre> |
80 |
<p> |
81 |
</p> |
82 |
<h4><a name="enable_libtrash_at_login">enable libtrash at login</a></h4> |
83 |
<pre> |
84 |
Include this in your ~/.bash_profile(or for system-wide usage in /etc/profile) |
85 |
to enable libtrash every time you log in (or otherwise start a login shell)</pre> |
86 |
<pre> |
87 |
#-------------- snip --------------------------- |
88 |
LIBTRASH=/usr/lib/libtrash/libtrash.so</pre> |
89 |
<pre> |
90 |
LIBTRASH_dest=$LIBTRASH |
91 |
if test -L $LIBTRASH ; then |
92 |
LIBTRASH_dest="$(dirname $LIBTRASH)/$(ls -l "$LIBTRASH" | \ |
93 |
sed -e 's/^.\+ -> //')" |
94 |
fi</pre> |
95 |
<pre> |
96 |
if test x${LD_PRELOAD+set} = x -a -f "$LIBTRASH_dest" ; then |
97 |
LD_PRELOAD="$LIBTRASH" |
98 |
export LD_PRELOAD |
99 |
if test x$0 = x-bash ; then |
100 |
exec bash ${1+"$@"} |
101 |
else |
102 |
exec $0 ${1+"$@"} |
103 |
fi |
104 |
fi |
105 |
#-------------- end snip ---------------------------</pre> |
106 |
<p> |
107 |
</p> |
108 |
<h4><a name="create_user_specify_config">create user specify config</a></h4> |
109 |
<pre> |
110 |
- READ /etc/libtrash.conf !! |
111 |
- overwrite default values by setting up a ~/.libtrash for each user:</pre> |
112 |
<pre> |
113 |
# sample ~/.libtrash: |
114 |
#-------------- snip --------------------------- |
115 |
GLOBAL_PROTECTION = YES |
116 |
INTERCEPT_FOPEN = YES |
117 |
INTERCEPT_FREOPEN = YES |
118 |
INTERCEPT_OPEN = YES |
119 |
IGNORE_HIDDEN = NO |
120 |
IGNORE_EXTENSIONS= o;exe |
121 |
#-------------- end snip ---------------------------</pre> |
122 |
<p> |
123 |
</p> |
124 |
<h4><a name="use_'cleantrash'_for_cleaning_trash_via_cronjob">use 'cleanTrash' for cleaning Trash via cronjob</a></h4> |
125 |
<pre> |
126 |
- gunzip & copy '/usr/share/doc/libtrash/examples/cleanTrash/ct2.pl.gz' |
127 |
to '/usr/local/bin/cleanTrash' e.g: |
128 |
|
129 |
'zcat /usr/share/doc/libtrash/examples/cleanTrash/ct2.pl.gz > /usr/local/bin/cleanTrash'</pre> |
130 |
<pre> |
131 |
- edit '/usr/local/bin/cleanTrash' for local configuration</pre> |
132 |
<p> |
133 |
</p> |
134 |
<h5><a name="insert_cronjob_for_root">insert cronjob for root</a></h5> |
135 |
<pre> |
136 |
- crontab -e (as root) |
137 |
- insert: 3,13,23,33,43,53 * * * * root /usr/local/bin/cleanTrash</pre> |
138 |
<p> |
139 |
</p> |
140 |
<h3><a name="important_notes">Important Notes</a></h3> |
141 |
<dl> |
142 |
<dt><strong><a name="item_gerneral">Gerneral</a></strong><br /> |
143 |
</dt> |
144 |
<dd> |
145 |
<pre> |
146 |
READ /etc/libtrash.conf !! |
147 |
If libtrash.so is global enabled via /etc/profile, a DEFAULT or WRONG ~/.libtrash configuration would |
148 |
causes gdm, root writes(if root writes are also protected by lintrash), kde etc. stops working !! |
149 |
|
150 |
solution to disable libtrash in enviroment immediately: |
151 |
- export LD_PRELOAD=""</pre> |
152 |
</dd> |
153 |
<dt><strong><a name="item_xterm">XTerm</a></strong><br /> |
154 |
</dt> |
155 |
<dd> |
156 |
<pre> |
157 |
to get a login shell, start XTerm with '-ls' (~/.profile will not be executed if not)</pre> |
158 |
</dd> |
159 |
</dl> |
160 |
<p> |
161 |
</p> |
162 |
<h3><a name="resources">Resources</a></h3> |
163 |
<dl> |
164 |
<dt><strong><a name="item_libtrash_%2d_implements_a_%22trash_can%22_under_gn">Libtrash - Implements a ``trash can'' under GNU/Linux</a></strong><br /> |
165 |
</dt> |
166 |
<dd> |
167 |
<pre> |
168 |
<a href="http://www.m-arriaga.net/software/libtrash/">http://www.m-arriaga.net/software/libtrash/</a></pre> |
169 |
</dd> |
170 |
</dl> |
171 |
<p> |
172 |
</p> |
173 |
<h3><a name="authors">Authors</a></h3> |
174 |
<pre> |
175 |
Sebastian Utz seut@tunemedia.de</pre> |
176 |
<p> |
177 |
</p> |
178 |
<h3><a name="last_changes">Last changes</a></h3> |
179 |
<pre> |
180 |
Revision 1.1 2003/01/24 17:47:49: |
181 |
+ create new</pre> |
182 |
|
183 |
</body> |
184 |
|
185 |
</html> |