3_ Ways to Permanently and Safely Delete Files and Directories in _Linux_

Summary: In most cases, we are used to delete files from our computer using the Delete key, trash or rm command, but this is not a way to permanently and safely delete files from our hard drive (or any storage medium). The file is just hidden from the user, it resides somewhere on the hard drive.

In most cases, we are used to deleting files from our computer using the Delete key, trash or rm command, but this is not a way to permanently and safely delete files from a hard drive (or any storage medium).

The file is just hidden from the user, it resides somewhere on the hard drive. It could potentially be recovered by data thieves, law enforcement forensics, or other means.

Assuming the file contains classified or confidential content, such as usernames and passwords for a security system, an attacker with the necessary knowledge and skills can easily recover a copy of the deleted file and access those user credentials (you can guess the consequences of this).

In this article, we will explain some command line tools for permanently and safely deleting files in Linux.

1. shred - Overwrite file to hide content
shred overwrites a file to hide its content, and optionally deletes it as well.

$ shred -zvu -n 5 passwords.list
In the command below, the options are:

-z - overwrite with zeros to hide shards
-v - show operation progress
-u - truncate and delete files after overwriting
-n - specify overwriting files The number of times for the content (default 3)
shred - overwrite a file to hide its content
shred - overwrite a file to hide its content

You can find more usage options and information in shred's help page:

$ man shred
2. wipe – Securely delete files in Linux The
wipe command securely wipes files from the disk, making it impossible to recover deleted files or directory contents.

First, you need to install the wipe tool, run the following appropriate command:

$ sudo apt-get install wipe [Debian and derivatives]
$ sudo yum install wipe [RedHat based systems]
The following command will destroy all files in the private directory .

$ wipe -rfi private/*
when the following flags are used:

-r - tell wipe to wipe subdirectories recursively
-f - enable forced deletion and disable confirmation queries
-i - show wipe progress
wipe Securely wipe files in Linux
wipe – Securely Wipe Files in Linux

Note : wipe only works reliably on magnetic storage, so use other methods for solid state disks (memory).

Read the wipe manual for other usage options and instructions:

$ man wipe
3. Secure delete toolset in Linux
secure-delete is a collection of secure file deletion tools that includes the srm (secure_deletion) tool for securely deleting files.

First, you need to install it using the relevant command:

$ sudo apt-get install secure-delete [Debian and derivatives]
$ sudo yum install secure-delete [RedHat-based systems]
Once installed, you can use the srm tool to securely delete files and directories in Linux.

$ srm -vz private/*
Here are the options used:

-v - enable verbose mode
-z - wipe last write with 0 instead of random data
srm securely delete files
in linux srm - securely delete files in linux

Read the srm manual for more usage options and information:

$ man srm
4. sfill - secure free disk/inode space wiper
sfill is part of the secure-deletetion toolkit and is a secure free disk and inode space wiper Remover, which deletes files from free disk space in a safe way. sfill checks for free space on the specified partition and fills it with random data from /dev/urandom.

The following command will execute sfill on my root partition, using the `-v' option to enable verbose mode:

$ sudo sfill -v /home/aaronkilik/tmp/
Assuming you created a separate partition /home to store normal system users home directory, you can specify a directory on that partition to apply sfill on:

$ sudo sfill -v /home/username
You can see some limitations in the manual for sfill, you can also see additional usage flags and command:

$ man sfill
NOTE: Two other tools in the secure-deletetion toolkit (sswap and sdmem) are not directly relevant to the scope of this guide, but for future use and knowledge dissemination purposes, we describe them below.

5. sswap – Secure Swap Eraser
It is a secure partition eraser, sswap deletes the data existing on the swap partition in a secure manner.

Warning: Remember to unmount the swap partition before using sswap! Otherwise your system may crash!

To find the swap partition (and to check if paging and swap devices/files are already in use, use the swapon command), next, use the swapoff command to disable paging and swap devices/files (making the swap partition unavailable).

Then run the sswap command on the (closed) swap partition:

$ cat /proc/swaps
$ swapon
$ sudo swapoff /dev/sda6
$ sudo sswap /dev/sda6 #This command will take some time, by default it will do 38 wipes
sswap secure swap wiper
sswap – secure swap wiper

Read the sswap manual for more options and information:

$ man sswap
6. sdmem – secure memory wiper
sdmem is a secure memory wiper designed to The purpose is to delete data in memory (RAM) in a safe manner.

It was originally named smem, but because of the existence of another package on Debain systems, smem - which reports memory consumption per process and per user, the developers decided to rename it to sdmem.

$ sudo sdmem -f -v For
more usage information, read the manual of sdmen: $

man
sdmem

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326236304&siteId=291194637