How to Permanently and Securely Delete a Files & Directory in Linux

In the Linux operating system, a deleted file finds its way into the Trash. When the Trash is emptied, the file is deleted from the system. However, with the increasing demand for recovery software, the files deleted from the Trash can be recovered up to a certain extent. This means the file which was removed from the Trash was never deleted permanently, but just became invisible to your eyes. The file is still somewhere on your hard drive occupying unnecessary space and will only be completely removed when a new file is created and is stored on those same sectors of your hard drive. To recover preciousdisk space and avoid file corruption, it is important to delete a file in Linux permanently.

Also Read: How to Check and Manage Disk Space in Linux?

Here Are Few Steps To Permanently Delete A File In Linux Operating System.

Due to variations present in Linux operating system and several available Distros like Ubuntu, Mint, Fedora etc, the steps to delete a file in Linux may vary in steps, but the basic concept behind deleting files and folders remains the same. The most common steps which can permanently delete directories in Linux without having to format your Hard disk are:

Method 1. Remove the Trash Option

There is an option, which when selected, allows the user to delete a file in Linux directly without sending them to trash. Enabling this option varies in different types of Linux, but the process used behind this feature can be either of the two mentioned below:

  • Reduce the Trash Limit.

If your Linux distro supports Dolphin file manager, then access the preferences and place a checkmark next to the box labelled Size and set the percentage limit to the lowest value. This will ensure that all files larger than the size set will not be stored in the Trash and will be deleted permanently.

Reduce the Trash Limit

  • If your Linux is using Nautilus or Nemo file manager, then you will get an option in the File Manager Preferences to enable Bypass the Trash when the Delete key is pressed. This will not move any deleted file to the Trash.

bypass the trash

Also Read: Best Linux Desktop Environments

Method 2. You can always Shred the Files

Developed by GNU Project, Shred is a program embedded in Linux operating system, which can be used to delete a file in Linux permanently . The command line deleting a document file by the name of Test using Shred is:

shred -uvz -n 2 Test.doc

The “u” parameter removes the file before overwriting it.

The “v” parameter displays verbose information.

The “z” parameter prevents any chances of recovery of the deleted data.

The “-n 2” parameter specifies additional passes for extra security.

In case, there are multiple files in a folder by the name of Music and you want to delete all of them, then use this command:

shred -uvz -n 2 Music/*.*

The name of the folder is specified as Music and the Asterix with a period and followed by another Asterix specifies to delete a file in Linux irrespective of their name or extension.

Also Read: 11 Linux Apps You Must Install On Your PC

Method 3. Use Wipe.

The Linux Software distribution centre will allow you to install Wipe on your Linux Distro. It is like Shred program and is easy to use. The command line for deleting a file through Wipe is:

wipe Music/song1.mp3

Wipe is more secure than Shred and this means it is time-consuming as well. It also requests a confirmation from the user. To quicken the process, use appropriate flags such as:

f: using this flag will remove the confirmation.

c: wipe the file despite permissions.

q: quicken the process by bypassing all the security passes.

r: delete from a folder in Linux.

The simple Wipe command with all the flags would now appear as:

wipe -rfcq Music/song1.mp3

Method 4. Use Secure Delete.

Another tool that ensures removal of data from a hard drive is SRM, which is bundled in the Secure Delete suite. It is a quite efficient and quick tool and can even delete a directory in Linux. The command to delete a file is:

SRM is one of the tools in the Secure Delete suite of tools that specializes in secure removal of data from your HDD. It’s held by many as the best tool for this job.

Srm Music/song1.mp3

Like Wipe, deleting a file by SRM is a time-consuming process and can be made aster using flags. Some important flags are:

z: your file will be deleted and overwritten by zeros replacing the file for extra security.

v: this flag will provide verbose information about the process.

r: this will enable the recursive mode for subfolders.

1: the number one. This will reduce the time taken to complete the process.

The new command would then be:

srm -rlvz Music/Song1.jpg

Also Read: Best Methods To Secure Linux Desktops

Method 5. Install Bleachbit (GUI)

Install Bleachbit

One of the best tools to find and delete unwanted files and even delete folders in Linux operating system is Bleachbit. It is known to free up space by securely erasing data that has not been used for a long time and can be used manually to target a few files that need to be deleted. It can be installed through the software centre by using the following command:

sudo apt install bleachbit

Once installed, run the interface and click on EDIT and choose Preferences. In the General Tab, there would be a list of different options. Place a checkmark in the box beside the option labelled as “Overwrite contents of files to prevent recovery”.

Next, to permanently delete a file on Linux, click File and choose Shred option. A prompt box will appear confirming your action. Click on Delete, and that will the last of the files selected.

The Final Word On Delete A File In Linux.

Although using a Linux operating system is a different experience, it is not difficult. All you must know the functions and features that are embedded in Linux. Being an Open-source, Linux has many options to do the same task, and these are some of the easy ones to delete a file in Linux permanently.

Leave a Reply

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

Subscribe Now & Never Miss The Latest Tech Updates!

Enter your e-mail address and click the Subscribe button to receive great content and coupon codes for amazing discounts.

Don't Miss Out. Complete the subscription Now.