srm

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.

srm (or Secure Remove) is a command line utility for Unix-like computer systems for secure file deletion.

Source: Wikipedia

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:

Debian and its based distrosFedoraredhat / CentOS / Scientific LinuxSUSE / openSUSEMageiaArchLinux and its based distrosGentooVoid LinuxAlpine LinuxFreeBSDMacOS X

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 SUSE / openSUSE:

$ zypper in srm

On Mageia:

$ urpmi srm

On ArchLinux and its its derivatives: (like: ManjaroKaOS / ArchBang Linux / BlackArch Linux / Parabola GNU/Linux-libre / Chakra GNU/Linux):

$ pacman -S srm

On Gentoo:

$ emerge app-misc/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-NAME

To securely remove all files in the current directory:

$ srm -vr *

While:

  • -v : Verbose mode.
  • -rRecursive mode, deletes all subdirectories.

For more information, check the manual:

$ man srm

Or read it online: srm(1)

By DeaDSouL

A big fan of UNIX & Linux.. Who adores programming..

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.