The Linux command srm allows you to securely delete files by overwriting them multiple times, ensuring that the files are completely removed. Many Linux users typically use the rm command to delete files. However, files deleted using rm are not truly erased; traces remain on the disk, making them recoverable through data recovery programs. For this reason, in environments where sensitive data is handled or security is crucial, a command that can fully delete files is needed. One such command is srm.
Table of Contents
What is the Linux Command srm?
srm stands for “secure remove,” and it is used to delete files in a way that makes them impossible to recover. It overwrites the data on the disk multiple times, leaving no trace behind, making it especially useful for deleting sensitive information or confidential company files.
The default behavior of srm is to overwrite the file 38 times, using the following method: First, all bits of the file are filled with 1s. Then, the file is overwritten five times with random values. Next, it is overwritten 27 times with specific values as defined by Peter Gutmann. Finally, the file is overwritten five more times with random values, the filename is renamed with random characters, and the file is permanently deleted.
srm vs rm
The main difference between rm and srm is in how they delete data. While rm simply deletes the file’s reference, leaving the data intact on the disk (making it recoverable), srm overwrites the data multiple times, making recovery extremely difficult. Another command with similar functionality is wipe.
How to Install srm
Most Linux distributions do not include the srm command by default, so you will need to install it separately. On Ubuntu or Debian-based systems, you can install it with the following command:
sudo apt install secure-deleteShellScriptOnce installed, you can start using the srm command.
Basic Usage of srm
The basic usage of the srm command is quite simple. To delete a file, just type srm followed by the file path.
srm filenameShellScriptFor example, if you want to delete a file named example.txt, you would enter the following command:
srm example.txtShellScriptThis will fully delete the example.txt file by overwriting it multiple times. Once the deletion process is complete, the command prompt will return without any additional messages.

Main Options for the srm Command
The srm command provides several options that allow you to customize how files are deleted. Below are the key options:
-r (recursive)
This option is used when you want to delete all files within a directory. With the -r option, you can delete a directory along with all its files and subdirectories.
srm -r subdirShellScript-v (verbose)
If you want to see detailed information about the deletion process, use the -v option. This will show you the progress of the deletion in the terminal.
srm -v filenameShellScriptWhen using the -v option, you can view the detailed steps of the file deletion as shown in the example below.

-l (less secure)
If you want to use a slightly less secure deletion method, the -l option is available. By default, srm overwrites files 38 times for maximum security, but using the -l option reduces the number of overwrites to 2, speeding up the process.
srm -l filenameShellScriptWith the -l option, files are overwritten only twice—once by filling all bits with 1s and once with random values.

-f (fast and insecure mode)
The -f option allows for fast deletion in an insecure mode. It does not use /dev/urandom or synchronization mode for overwriting files.
srm -f filenameShellScriptAlthough the deletion process remains at 38 overwrites, the -f option skips random value overwriting and synchronization.

-z (zero)
After overwriting the file 38 times, the -z option writes zeros to the remaining free space on the disk. This option is useful when you want to completely fill all the freed space with zeros after deleting files.
srm -z filenameShellScriptUsage Considerations
There are a few things to be aware of when using the srm command:
- Irreversibility: Unlike the
wipecommand, which prompts for confirmation before deletion,srmdeletes files immediately without asking. Once deleted, files cannot be recovered, so double-check before deletion. Always verify the files you are about to delete. - Performance Impact: Since
srmoverwrites files multiple times, it takes longer to delete files compared to thermcommand. For large files or many files, this process can be significantly slower. - Disk Wear: Overwriting files multiple times can shorten the lifespan of SSDs and other flash-based storage devices. Be cautious when using the
srmcommand on such devices.
Useful Applications
The Linux command srm is especially valuable in environments where security is critical. Here are some scenarios where it can be applied:
- Personal Data Protection: Use
srmto securely delete sensitive personal or customer data, preventing any possibility of leakage. - Disk Cleanup: When clearing out old files, you can use
srmto ensure that no traces of the deleted files remain. It’s particularly useful if you’re selling or transferring a disk to someone else, reducing the risk of data recovery.
Additionally, you can automate the deletion of sensitive files by including the srm command in a regular script. This makes it easier to manage confidential data without the need for manual deletion.
Summary
The Linux command srm is a powerful tool for securely deleting files, ensuring that they are unrecoverable. In environments where security is essential, using srm instead of rm is a smart way to manage sensitive data. However, you should be aware of the potential performance impact and the irreversibility of the deletion process. Moreover, care should be taken when using srm on SSDs and other flash-based storage devices to avoid unnecessary wear.