Tools to Securely Delete Files from Linux
Last Updated :
20 Feb, 2025
Every time you delete a file from your Linux system using the shift + delete or rm command, it doesn’t actually permanently and securely delete the file from the hard disk. When you delete a file with the rm command, the file system just frees up the appropriate inode but the contents of the old file are still in that space until it is overwritten which pave a way to recover the files.
The space that was used by the file that you deleted is now free to be used by other new files. But the contents of the old files are still in the hard disk, Until and unless that space is overwritten by something else, so there is a good chance that the file can be recovered by anyone (maybe by some data thieves) with good knowledge of recovering data. It is like removing the index page of a book, where the chapters are still there, it just becomes much hard to find, but we can find it.
Tools to Securely Delete Files from Linux
Method 1: Using Shred
Shred will help you to overwrite a deleted file, so it becomes difficult to recover it. It is like tearing a paper into as many pieces as you want or overwriting over the paper so that it becomes impossible to find out the original data.

manual of shred

shred
In the above output, the meaning of the letters are:
- -u: deallocates and removes file after overwriting
- -v: enables the display of operation progress
- -z: adds a final overwrite with zeros to hide shredding
- -n: total number of times the file content will be overwritten(I gave 6).
Secure-delete is a command containing a set of secure file deletion tools containing srm (secure_deletion) tool which is used to delete or overwrite the files securely in Linux.
Â
At first, we have to install it by typing:
sudo apt-get install secure-delete

install secure-delete
There is a total of 4 different types of tools consisting of this whole package and each of them performs a different type of securely delete operation. They are as follows:-
- srm : It is a secure rm that is used to erase files by overwriting their hard disk space and deleting them.
- sfill : It is used to overwrite free space on the hard disk.
- sswap : It is used to overwrite swap space.
- sdmem : It is used to wipe the RAM Once secure-delete is installed.
# srm Command:
srm command deletes anything just like rm command but securely i.e by overwriting the file and its inode with random bytes. The larger the file, the longer it takes to wipe and rewrite it.

srm tool
Type srm man to get more information:

 manual
Method 3: Using Wipe.
The Linux wipe command allows us to securely erase data from our hard disk permanently. The wipe command erases files from magnetic memory and rewrites the space repeatedly and wipe away the caches which make the data nearly impossible to be recovered.Â
At first, we have to install a wipe:

sudo apt-get install wipe
Now you can use wipe for secure deletionÂ

wipe
To know more about each function check wipe -h:

manual of wipe command
Method 4: Using dd:
dd command is especially used to convert or copy files. We can use this command to completely overwrite your hard drive with zeros, but DD will not zero a drive currently in use
The syntax is :
- dd if=<source> of=<target> [Options]

In the above menu:
- lsblk: Lists all the disks
- /dev/urandom  (input): The random data used for overwriting
- /dev/sda (output): the disk that will be overwritten. This disk will be replaced with random garbage data.Â
See the help menu of the “dd” command for more details:

Also Read:
Conclusion
When you delete files in Linux using the rm command or Shift + Delete, the data is not permanently erasedâit remains recoverable until overwritten. To ensure secure file deletion and prevent unauthorized data recovery, specialized tools like Shred, Secure-Delete, Wipe, and dd are essential.
- Shred repeatedly overwrites files, almost making them irrecoverable.
- Secure-Delete (srm, sfill, sswap, sdmem) offers several different options for securely erasing files, free space, swap, and RAM.
- Wipe permanently deletes data by writing over magnetic memory several times
- dd supports full disk wiping with random data in order to provide irreversible erasure
With these safe deletion techniques, you can protect confidential data and make your system immune to data leaks, identity theft, and illicit recovery attempts. As an IT administrator, security expert, or privacy advocate, it is important to implement data sanitization best practices for Linux security and confidentiality.
Tools to Securely Delete Files from Linux- FAQs
How do you securely delete files in Linux?
Use the shred command to overwrite a file before deleting it:
shred -u filename
For complete disk wiping, use wipe or dd.
What tool is used to securely delete files?
Common tools include shred, wipe, srm (Secure Remove), and dd.
How do you safely delete a folder in Linux?
Use rm -r foldername for regular deletion or srm -r foldername for a secure wipe
What is the most secure way to delete files?
The shred command overwrites data multiple times, making recovery nearly impossible:
shred -n 35 -u filename
How to delete protected files in Linux?
Use sudo with rm:
sudo rm -f filename
If immutable, remove the attribute first:
sudo chattr -i filename
sudo rm filename
How do I delete a folder in Linux without permission?
Use sudo for admin privileges:
sudo rm -rf foldername
If permission issues persist, change ownership first:
sudo chown -R $USER foldername
sudo rm -rf foldername
Similar Reads
Tools to Securely Delete Files from Linux
Every time you delete a file from your Linux system using the shift + delete or rm command, it doesn't actually permanently and securely delete the file from the hard disk. When you delete a file with the rm command, the file system just frees up the appropriate inode but the contents of the old fil
5 min read
How to Delete Files in Linux?
Linux comes with several tools that can assist us in removing Directories and files. We always need to delete many files and folders based on a set of requirements. To complete our mission quickly, knowing a few basic commands and their variations is beneficial. Use caution when using the commands b
6 min read
How to delete from a pickle file in Python?
Python pickle module is used for serializing and de-serializing a Python object structure. Any object in Python can be pickled so that it can be saved on disk. What pickle does is that it âserializesâ the object first before writing it to file. Pickling is a way to convert a python object (list, dic
3 min read
How to Recover Deleted Files Using Foremost in Linux?
Foremost is a digital forensic application that is used to recover lost or deleted files. Foremost can recover the files for hard disk, memory card, pen drive, and another mode of memory devices easily. It can also work on the image files that are being generated by any other Application. It is a fr
3 min read
How to Recover a Deleted File in Linux?
We all have often faced a problem where we have accidentally deleted some files in Linux, that we regretted deleting later on after we did not even find it in the trash. But what if we can recover them? Here, we will discuss How we can recover a Deleted File in Linux. Whenever we delete something fr
4 min read
How to delete data from file in Python
When we no longer require data, we usually prefer to erase or delete it so that space can be used up by other data that is important to us. Python too supports file handling and allows users to handle files i.e., to read and write files, along with many other file handling options, to operate on fil
3 min read
How to Permanently Delete Files from Dropbox?
Dropbox is a popular cloud storage service that permits clients to store, access, and share files from any place. Be that as it may, there may come a time when you need to permanently erase records from Dropbox, ensuring that they are not recoverable. Whether itâs for freeing up space or protecting
4 min read
How to Remove Deleted Files from a Git Repo?
Managing files in a Git repository often involves adding, modifying, and deleting files. However, sometimes files are deleted from the disk but remain tracked in the repository. To keep your repository clean and in sync with your working directory, you need to remove these files from the repository
3 min read
How to Delete a File From a Git Repository?
Managing files within a Git repository often involves adding new files, modifying existing ones, and sometimes, deleting files that are no longer needed. Deleting a file from a Git repository is a simple process, but it's essential to follow the correct steps to ensure that the repository remains co
3 min read
PhotoRec Recover Deleted or Lost Files in Linux
It is quite a common requirement for users wanting to access the files that they have deleted in the past. This is partly due to misjudgment of the importance of the file, deletion of the file by malicious software, or loss of file due to a File system corruption. Whatever the reason may be, sometim
4 min read