+5 votes
68 views
Securely delete files Linux

in Linux/Unix by (552k points)
reopened | 68 views

1 Answer

+3 votes
Best answer

1 Safely Delete Linux Files from Recycle Bin
2 Securely Erase Linux Files Using Wipe
3 Securely delete files Linux using Shred
4 Securely delete files Linux using Secure delete
5 Securely Erase Files Linux Using DD
6 Securely Erase Linux Files Using Bleachbit

In Linux, regardless of the distribution used, it is normal that in our daily activities we handle many types of data that, due to their content, must be done securely when they are deleted so that said content is not exposed. The reason for this is that when delete a file, this by default eliminates only the reference to the file in the system file system, that is, with this the true content of this file will continue on the hard disk, privacy will be vulnerable because if another user accessing the hard drive will be able to recover those deleted files and thus put their privacy at risk..

 

Sometimes it is not enough to copy or move Linux folders and we need to directly delete them. When performing a secure deletion, the action that is executed is to overwrite the space on the disk where that data was stored, this will prevent the recovery of this information, TechnoWikis will explain various ways to achieve this task in Linux.

 

 

 

To stay up to date, remember to subscribe to our YouTube channel!
SUBSCRIBE ON YOUTUBE

 

 


1 Safely Delete Linux Files from Recycle Bin


The first action is integrated into the system itself and is the Recycle Bin, in this case we will use Ubuntu, when deleting a file by pressing the Delete key or using the context menu, this file will be stored in the Trash for a while and we can recover it No problem, but the goal is to safely remove it.

 

Step 1

We open the Recycle Bin. There we find all the files, we click on "Settings" to

 

image

 

Step 2

We can adjust the values ​​as necessary:

 

image

 

Step 3

There it will be possible to perform tasks such as:

 

  • Host the history of stored files
  • Automatically delete the trash
  • Delete temporary automatically
  • Set the number of days files will be in the Trash and more

 

Step 4

To delete them we select the files and click on "Empty":

 

image

 

step 5

We will see the following message:

 

image

 

step 6

Confirm the process and the Trash will be empty:

 

image

 

 


2 Securely Erase Linux Files Using Wipe


Wipe is a command used and created to safely delete files and directories, this command is responsible for overwriting the data of the file or directory using random information, thus avoiding the recovery of the information, wipe can be used either on individual files or on entire directories along with their content.

 

Wipe Options
Some of the general Wipe options are:

 

  • -a: Abort the process
  • -c: chmod write-protected files
  • -D: removes the reference in symbolic links
  • -e: makes use of the exact size of the file
  • -f: do not ask for confirmation of actions
  • -i: Informational mode
  • -k : keep files, i.e. do not delete them after overwriting
  • -M (l|r): sets the PRNG algorithm to fill blocks
  • a: use arcfour encryption algorithm
  • -P <passes>: defines the number of passes to delete the file name
  • -Q <number>: sets the number of passes to perform a quick wipe
  • -s: use silent mode
  • -T <attempts>: defines the maximum number of attempts

 

 

Step 1

Open the terminal and install Wipe:
 sudo apt install wipe 
image

 

 

Step 2

We access the directory and list the content with "ls":

 

image

 

 

Step 3

We delete the file:
 wipe -rfcq -Q # ./file_name 
image

 

Step 4

Check that it has been deleted:

 

image

 


3 Securely delete files Linux using Shred

 

This command is responsible for repeatedly overwriting the selected file to prevent access to its information, it has advanced options as it allows us to customize the number of write passes, the pattern used to overwrite the data and some other parameters such as :

 

Shred Parameters
  • -f, --force: change permissions to allow writing
  • -n, --iterations=N: overwrites N times since the default is 3
  • -s, --size=N: execute the process on the indicated number of bytes
  • -u: unmap and delete the file after overwriting it
  • -v, --verbose: use verbose mode
  • -z, --zero: add a trailing override with zeros to hide the process

 

 

Step 1

We list the contents of the directory and then delete the element:
 shred -uvz -n # (file) 

image

 

Step 2

We confirm that the file has been deleted:

 

image

 


4 Securely delete files Linux using Secure delete


Basically Secure Delete has been developed as a group of files and directories which we can see under the name of srm (secure removal), this makes use of multiple algorithms to overwrite the file data thus preventing recovery.

 

Secure delete has several commands such as "srm", "sfill" and "sswap", these can be used to delete individual files, delete an entire directory or simply replace the deleted files in free disk space..

 

 

Secure Delete Parameters
Some of its usage parameters are:

 

  • -d: ignore colon special files "." and "..".
  • -f: use fast delete mode
  • -l: decrease deletion security
  • -r : use recursive mode by removing all subdirectories
  • -v: use verbose mode
  • -z: on last delete write zeros instead of random data to the file

 

 

Step 1

We open the terminal and install Secure delete:
 sudo apt install secure-delete 
image

 

Step 2

We access the directory and list the contents with "ls", then we delete the file safely:
 srm -vz (file) 
image

 

Step 3

Check that it has been deleted:

 

image

 


5 Securely Erase Files Linux Using DD


The DD (Data Definition) command is a command with various tasks such as copying and converting files and partitions, creating disk images, cloning disks and creating bootable media, but it also provides us with the possibility of secure erasure of information.

 

Step 1

In this case we open the terminal and we know the exact value of the file size:
 ls -l /file_path | awk '{print $5}' 
image

 

Step 2

Now we fill the file with null characters:
 dd status=progress bs=(file size) count=1 if=/dev/zero of=/file_path 
image

 

 

Step 3

We use the "rm" command to delete the file:
 rm /file_path 
image

 

Step 4

Validate that it has been deleted:

 

image

 

 


6 Securely Erase Linux Files Using Bleachbit


Finally, an ideal and graphic option to safely delete files in Linux is with Bleachbit, this is a free software app that allows us to both clean and free up space on the hard drive and is available for Linux, Windows and macOS.

 

Step 1

Among its advantages is that it allows us to delete temporary files, cache and more data in order to free up disk space or in this case safely delete the files, we open the terminal and install Bleachbit:
 sudo apt install bleachbit 
image

 

Step 2

Open Bleachbit:

 

image

 

 

Step 3

When we open it we will see a series of options:

 

image

 

Step 4

We can navigate through each tab to review the options:

 

image

 

step 5

It will be possible to configure the units where it will be analysed:

 

image

 

step 6

You can change your language:

 

image

 

step 7

We can add files to the White List so that they are not deleted:

 

image

 

step 8

Now we will see a hierarchical structure with the sites to manage:

 

image

 

 

step 9

Activate the box of the path where the files will be deleted:

 

image

 

step 10

We click on "Clean" and we must confirm the process:

 

image

 

 

step 11

We will be able to view the files that have been securely deleted in Linux. With this, these files will have been deleted.

 

image

 

Each of these tools will have the opportunity to delete our files safely without thinking that the data stored there can be easily recovered by another user.

 


by (3.5m points)
edited

Related questions

+5 votes
1 answer
+5 votes
1 answer
asked Oct 8, 2019 in Mac by backtothefuture (552k points) | 280 views
+3 votes
1 answer
asked Sep 20, 2019 in Security by backtothefuture (552k points) | 248 views
+5 votes
1 answer
asked Sep 7, 2023 in Linux/Unix by backtothefuture (552k points) | 58 views
+4 votes
1 answer
asked Dec 17, 2019 in Windows 10 by backtothefuture (552k points) | 258 views
Sponsored articles cost $40 per post. You can contact us via Feedback

Most popular questions within the last 30 days

10,659 questions
10,791 answers
510 comments
3 users