descriptionwrapper around the rm command to prevent accidental deletions
homepage URLhttps://launchpad.net/safe-rm
ownerfrancois@fmarier.org
last changeSat, 5 Sep 2020 20:07:24 +0000 (5 13:07 -0700)
content tags
add:
README.md

safe-rm

prevention of accidental deletions by excluding important directories

Copyright (C) 2008-2020 Francois Marier <francois@fmarier.org>

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.

How to use

Once you have installed safe-rm on your system (see INSTALL), you will need to fill the system-wide or user-specific exclusions with the paths that you'd like to protect against accidental deletion.

The system-wide exclusions live in /etc/safe-rm.conf (or /usr/local/etc/safe-rm.conf) and you should probably add paths like these:

/
/etc
/usr
/usr/lib
/var

The user-specific exclusions live in ~/.config/safe-rm and could include things like:

/home/username/documents
/home/username/documents/*
/home/username/.mozilla

Other approaches

If you want more protection than what safe-rm can offer, here are a few suggestions.

You could of couse request confirmation everytime you delete a file by putting this in your /etc/bash.bashrc:

alias rm='rm -i'

But this won't protect you from getting used to always saying yes, or from accidently using 'rm -rf'.

Or you could make use of the Linux filesystem "immutable" attribute by marking (as root) each file you want to protect:

chattr +i file

Of course this is only usable on filesystems which support this feature.

Here are two projects which allow you to recover recently deleted files by trapping all unlink(), rename() and open() system calls through the LD_PRELOAD facility:

There are also projects which implement the FreeDesktop.org trashcan spec. For example:

Finally, this project is a fork of GNU coreutils and adds features similar to safe-rm to the rm command directly:

shortlog
2020-09-05 Francois MarierUse actual release datemastersafe-rm-0.13
2020-08-29 Francois MarierBump date and version for release.
2020-08-29 Francois MarierConvert README to Markdown.
2020-08-29 Francois MarierUpgrade links to HTTPS and fix dead ones.
2020-08-29 Francois MarierUse consistent language for the lists of excluded paths
2020-08-29 Francois MarierAdd /usr/local/etc/safe-rm.conf as an alternative confi...
2014-12-17 Francois MarierSign the git tags
2014-11-03 Francois MarierBump date and version for releasesafe-rm-0.12
2014-11-03 Francois MarierRemove unnecessary dependency on Env
2014-10-07 Francois MarierBump date and version for releasesafe-rm-0.11
2014-10-07 Francois MarierMake user config file compliant with XDG Base Directory...
2014-06-22 Francois MarierFreshmeat (and freecode) has shut down
2014-01-01 Francois MarierDeprecate safe-rm.org.nz and bump copyright year
2014-01-01 Francois MarierReplace blog with LP announcements
2013-06-09 Francois MarierBump date and version for releasesafe-rm-0.10
2013-06-09 Francois MarierKeep .asc release files out of git
...
tags
3 years ago safe-rm-0.13 New upstream release
9 years ago safe-rm-0.12
9 years ago safe-rm-0.11
10 years ago safe-rm-0.10
11 years ago safe-rm-0.9
14 years ago release-0.8
14 years ago release-0.7
14 years ago release-0.6
15 years ago release-0.5 0.5 release
15 years ago release-0.4
15 years ago release-0.3
heads
3 years ago master