LinuxCommandLibrary

srm

Securely remove files and directories

TLDR

Remove a file after a single-pass overwriting with random data

$ srm [[-s|--simple]] [path/to/file]
copy

Remove a file after seven passes of overwriting with random data
$ srm -m [path/to/file]
copy

Recursively remove a directory and its contents overwriting each file with a single-pass of random data
$ srm [[-r|--recursive]] [[-s|--simple]] [path/to/directory]
copy

Prompt before every removal
$ srm [[-i|--interactive]] [\*]
copy

SYNOPSIS

srm [options] file...
srm [options] directory...

PARAMETERS

-f, --force
    Force removal, suppress prompting, and ignore non-existent files and arguments.

-i, --interactive
    Prompt before every removal. Overrides -f.

-r, -R, --recursive
    Remove directories and their contents recursively.

-s, --simple
    Use a faster, single-pass overwrite method with random data.

-m, --medium
    Use a 7-pass overwrite method, compliant with DoD 5220.22-M.

-g, --gutmann
    Use the Gutmann method, a 35-pass overwrite method for maximum security (slowest).

-v, --verbose
    Explain what is being done, showing each file and pass.

-z, --zero
    Overwrite with zeros for the final pass instead of random data. Default is random.

--version
    Display version information and exit.

--help
    Display help message and exit.

DESCRIPTION

srm, short for secure remove, is a command-line utility designed to securely delete files and directories by preventing their recovery. Unlike the standard rm command, which merely removes the file's directory entry, srm overwrites the file's content multiple times with various patterns (e.g., random data, zeros, ones) before truncating and unlinking it. This process adheres to secure data erasure standards, such as the Gutmann method or DoD 5220.22-M, making data virtually unrecoverable even with advanced forensic techniques. It is particularly useful for handling sensitive information, ensuring that all data blocks associated with the file are sanitized.

CAVEATS

srm is significantly slower than rm due to multiple overwrite passes.
Its effectiveness can be limited on modern storage devices like SSDs, NVMe drives, or RAID systems due to wear-leveling, over-provisioning, and data distribution by controllers, which can prevent srm from reaching all physical blocks where data may reside. For such media, physical destruction or full disk encryption is often more reliable. It also does not securely erase free disk space; use sfill(1) for that purpose.

SECURE DELETION PRINCIPLES

Simple file deletion (e.g., using rm) only removes the pointer to a file's data, making the space available for new data but leaving the original data blocks intact and recoverable. Secure deletion tools like srm are crucial because they ensure that the actual data on the storage medium is unreadable by overwriting it multiple times with specific patterns (zeros, ones, random data) before finally unlinking the file. This process is essential for compliance with data protection regulations and for protecting sensitive information.

LIMITATIONS ON MODERN STORAGE

While highly effective on traditional magnetic hard drives, srm's efficacy is reduced on Solid State Drives (SSDs) and other flash-based storage. This is due to internal SSD mechanisms like wear-leveling (distributing writes evenly), over-provisioning (reserving extra space for internal operations), and controller-managed data mapping. These features mean that data written to a logical block might not end up on the same physical block each time, and deleted data might persist in inaccessible areas. For ultimate security on SSDs, encryption or physical destruction is generally recommended.

HISTORY

srm is part of the secure-delete package, originally created by Todd Miller. This package was developed to provide a suite of tools for robust data sanitization on magnetic media, addressing the limitations of standard file deletion utilities. Its design principles are rooted in overwriting techniques used to prevent data recovery by sophisticated methods, making it a staple for secure file management in environments requiring strict data privacy.

SEE ALSO

rm(1), shred(1), wipe(1), sfill(1), sdel(1)

Copied to clipboard