In this tutorial we will learn how to install and use the srm command line tool to securely remove files on our system. To prevent or at least decrease the possibilities of recovering them.
Source: Wikipedia
srm(or Secure Remove) is a command line utility for Unix-like computer systems for secure file deletion.
As usual, become a root or use sudo whenever is needed with the following commands.
Installation:
srm isn’t usually installed on most Linux distributions by default. So, let’s first verify whether or not it’s being installed. Please, see : How to check whether or not a package is installed. Keep in mind if you’re using Debian based distro, then search for the package called secure-delete or search for the filename srm by using the flag --search with the command dpkg.
If it wasn’t installed, simply install it:
Such as: Debian / Ubuntu / Linux Mint / Devuan / elementary OS / MX Linux / antiX / deepin / Linux Lite / Zorin OS / LXLE / Peppermint OS / SparkyLinux:
$ apt install secure-delete
If apt wasn’t installed by default, then use apt-get or aptitude instead.
On Fedora:
$ dnf install srm
On RedHat 7 / CentOS 7 / Scientific Linux 7:
$ yum install srm
On RedHat 8+ / CentOS 8+ / Scientific Linux 8+:
$ dnf install srm
On Mageia:
$ urpmi srm
On ArchLinux and its its derivatives: (like: Manjaro / KaOS / ArchBang Linux / BlackArch Linux / Parabola GNU/Linux-libre / Chakra GNU/Linux):
$ pacman -S srm
On Void Linux:
$ xbps-install -S srm
On Alpine:
$ apk add srm
On FreeBSD:
To install the pre-compiled package:
$ pkg install srm
If you prefer to compile it yourself:
Using portmaster:
$ portmaster -v security/srm
Or, the traditional way:
$ cd /usr/ports/security/srm $ make install clean $ rehash
On MacOS X: It’s already installed by default.
Usage:
Then, use the srm command to securely remove the files:
$ srm -v FILE-NAMETo securely remove all files in the current directory:
$ srm -vr *While:
-v: Verbose mode.-r: Recursive mode, deletes all subdirectories.
For more information, check the manual:
$ man srmOr read it online: srm(1)
