What is safe-rm?
Safe-rm is a safety tool intended to prevent the accidental deletion of important files by replacing
/usr/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 - for example:
$ rm -rf /usr
Skipping /usr
(Protected paths can be set both at the site and user levels.)
Recovering important files you deleted by mistake can be quite hard. Protect yourself today by installing
safe-rm and reduce the likelihood that you will need to contact a data recovery service!
Installation is simple and easy:
1: Download the package
safe-rm-0.8.tar.gz from the following link:
http://code.google.com/p/safe-rm/downloads/list
2: Use the command
which rm to determine the current location of the original
rm command:
which rm/usr/bin/rm
3: As you can see, this returned the path to the
rm command as
:
/usr/bin/rm
4: Now we need to
un-archive this package with the following commands:
cd /usr/home/texasmike/Downloads (or the directory where safe-rm-0.8.tar.gz is saved)
tar -xvpf safe-rm-0.8.tar.gz This will create the Directory
safe-rm-0.8 within the current directory, and extract the files into that directory.
5: Copy/move the
/usr/bin/rm original file to an alternate name for backup purposes.
sudo mv /usr/bin/rm /usr/bin/rm-original6: Now copy/move the new
safe-rm to the
/usr/bin/ directory and rename to
rm :
sudo mv /home/texasmike/Downloads/safe-rm-0.8/safe-rm /usr/bin/rm(Use the appropriate path for the location of the extracted
safe-rm file)
You will now be using the new
safe-rm package when removing/deleting files by simply typing the command
rm filename.
Once you have installed
safe-rm on your system (look in the
safe-rm-0.8 directory for the INSTALL file), you will need to fill the system-wide or user-specific blacklists with the paths that you'd like to protect against accidental deletion.
The system-wide blacklist lives in
/etc/safe-rm.conf and you should probably add
paths like these:
/
/etc
/
usr/
usr/lib
/var
The user-specific blacklist lives in
~/.safe-rm and could include things like:
/home/
username/documents
/home/
username/documents/*
/home/
username/.
mozillaThis will keep you safe when deleting files and/or folders, knowing you can not make an error and cause damage to the operating system.
Print this post