Site icon Web Niraj

How to Securely Delete Files on Linux

I recently moved servers, so wanted to safely delete files on the one one, once all the files were moved safely across. To achieve this, I used the shred utility on AlmaLinux.

The shred command in Linux is a powerful tool designed to securely overwrite files, making it extremely difficult to recover their original contents. But use caution and test the commands on a non-critical data. Data erased with shred is intended to be irrecoverable.

Install the shred app:

sudo yum install shred

Running the Command:

shred -uvz file.ext

When using shred in this context, several options are crucial:

Shredding a Directory

The shred utilitiy does not directly operate on directories. To apply shred to all files within a directory and its subdirectories, you need to use it in conjunction with other commands, typically find.

find /path/to/your/directory -type f -exec shred -uvz file.ext {} \;

Important Caveats and Considerations:

Exit mobile version