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
Step 2
We can adjust the values as necessary:
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":
step 5
We will see the following message:
step 6
Confirm the process and the Trash will be empty:
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:
- -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
- -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
- -T <attempts>: defines the maximum number of attempts
Step 1
Open the terminal and install Wipe:
sudo apt install wipe
Step 2
We access the directory and list the content with "ls":
Step 3
We delete the file:
wipe -rfcq -Q # ./file_name
Step 4
Check that it has been deleted:
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)
Step 2
We confirm that the file has been deleted:
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 "..".
- -l: decrease deletion security
- -r : use recursive mode by removing all subdirectories
- -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
Step 2
We access the directory and list the contents with "ls", then we delete the file safely:
srm -vz (file)
Step 3
Check that it has been deleted:
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}'
Step 2
Now we fill the file with null characters:
dd status=progress bs=(file size) count=1 if=/dev/zero of=/file_path
Step 3
We use the "rm" command to delete the file:
rm /file_path
Step 4
Validate that it has been deleted:
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
Step 2
Open Bleachbit:
Step 3
When we open it we will see a series of options:
Step 4
We can navigate through each tab to review the options:
step 5
It will be possible to configure the units where it will be analysed:
step 6
You can change your language:
step 7
We can add files to the White List so that they are not deleted:
step 8
Now we will see a hierarchical structure with the sites to manage:
step 9
Activate the box of the path where the files will be deleted:
step 10
We click on "Clean" and we must confirm the process:
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.
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.