Linux Command wipe Usage and 5 Options

The Linux command wipe is a command that ensures complete deletion of data by overwriting files or directories multiple times. In this post, we will explore the basic usage of the wipe command, key options, and how to securely delete data.

What is the Linux Command wipe?

In Linux, there are several commands for deleting files. Usually, the rm command is used, which simply removes the file from the index but does not actually erase the data. This means that the deleted file can be restored using file recovery programs.

The wipe command, however, ensures that data is irrecoverable. It repeatedly overwrites the space where the file data is stored with random data, making it impossible to recover.

Basic Usage of the wipe Command

We’ll focus on Ubuntu Linux. The wipe command is not included by default in Ubuntu, so you’ll need to install it via the package manager.

sudo apt install wipe
ShellScript

Once installed, the wipe command can be used as follows:

wipe [options] [filename]
ShellScript

Here, [options] are optional, and you can specify the file name as needed.

For example, to permanently delete a specific file, you can use the following command. This will completely overwrite and delete the data of the file myfile.txt. After this, the file cannot be recovered.

wipe myfile.txt
ShellScript

When you run the command, you’ll be asked “Okay to WIPE 1 regular file?” You must type “Yes” in full to proceed. Simply typing “y” won’t delete the file. This is likely because the wipe command ensures that the file is irrecoverable, so the system prompts for confirmation with a full “Yes.” Once you confirm by typing “Yes,” the progress will be shown, and the command will indicate that 1 file has been wiped.

Figure 1. Linux command wipe: Basic deletion (35 overwrites)
Figure 1. Linux command wipe: Basic deletion (35 overwrites)

Key Options

The wipe command comes with several options. By using these options, you can delete data more securely depending on the situation. Here are some frequently used options:

-r: Delete Directory

The -r option is used to delete all files in a directory. Similar to the rm command, the wipe command can recursively delete directories. This command will completely delete the directory mydirectory and all files and subdirectories within it.

wipe -r mydirectory/
ShellScript

Below is an example using the -r option to delete the directory named subdir. The process of overwriting each file is shown, and it confirms that 6 files and 1 directory have been deleted.

Figure 2. Linux command wipe: Deleting subdirectories
Figure 2. Linux command wipe: Deleting subdirectories

-q: Quick Deletion

By default, the wipe command overwrites data 35 times to ensure secure deletion. However, this can slow down the process. If speed is a priority over security, you can use the -q option for quick deletion.

wipe -q myfile.txt
ShellScript

This option reduces the number of overwrites to 4 using random patterns, speeding up the deletion process. However, note that fewer overwrites may increase the chance of recovery. As shown below, the term “pass 3” indicates that the file was overwritten 4 times (from 0 to 3).

Figure 3. Linux command wipe: Quick deletion (4 overwrites)
Figure 3. Linux command wipe: Quick deletion (4 overwrites)

-Q: Specify Number of Overwrites

When using the -q option, the default number of overwrites is 4. If you want to change this number, you can use the -Q option. Note that the -Q option must be used in combination with the -q option.

wipe -q -Q 6 myfile.txt
ShellScript

Below is the result of specifying 15 overwrites.

Figure 4. Linux command wipe: Specifying 15 overwrites for quick deletion
Figure 4. Linux command wipe: Specifying 15 overwrites for quick deletion

-f: Force Deletion Without Confirmation

As mentioned earlier, the wipe command will ask for confirmation with “Okay to WIPE 1 regular file?” when deleting files. Using the -f option allows you to skip this prompt and delete the file immediately.

wipe -f myfile.txt
ShellScript

As shown below, the file will be deleted without asking for confirmation. Be careful not to accidentally delete important system or configuration files.

Figure 5. Linux command wipe: Forced deletion with -f option
Figure 5. Linux command wipe: Forced deletion with -f option

-i: Show Detailed Information

The -i option provides additional information, such as the size of the file being deleted.

wipe -i myfile.txt
ShellScript

Below, you can see the result of using the wipe command to delete video.mp4 and also displaying its file size.

Figure 6. Linux command wipe: Displaying file size with -i option
Figure 6. Linux command wipe: Displaying file size with -i option

Precautions When Using the wipe Command

The wipe command is a very powerful data deletion tool, so there are several things to keep in mind when using it.

  1. Irrecoverable: Once you use the wipe command, the data cannot be recovered. Be cautious not to accidentally delete important files.
  2. Speed: The deletion process can take a long time depending on the size of the data and disk speed. Especially when deleting entire directories, the process may be slower. Make sure to account for this before starting the deletion.
  3. System Files: Be very careful when using the -f option. Deleting system or configuration files by mistake could damage your system.
  4. SSD Lifespan: If you’re using a Solid State Drive (SSD), be aware that constant overwriting can negatively impact the lifespan of the drive. The wipe command should only be used when absolutely necessary to avoid unnecessary wear.

Useful Applications

The wipe command is particularly useful in environments where security is a priority, or when you need to safely delete personal files. For instance, if you are handling financial data or personal information, you can use the wipe command to ensure the data is securely deleted. It can also be used to wipe entire hard drives or external disks using the -r option.

Additionally, before selling a used computer or hard drive, it’s a good idea to use the wipe command to securely wipe the entire disk. This ensures that your personal information remains protected.

Summary

When deleting files, simply using the rm command may not always be sufficient. While combining shred with rm can address some issues, this approach can be cumbersome. With the Linux command wipe, you can handle the entire process of overwriting and deleting files in one step.

The Linux command wipe ensures that data is overwritten multiple times, making it irrecoverable. This makes it a very useful tool for securely deleting important files on servers or personal computers.

By utilizing the options provided by the wipe command, you can tailor it to your specific needs, such as quick deletion or deleting entire directories. However, always be mindful that once files are deleted using this command, they cannot be recovered.

By using wipe, you can maintain security and safely manage your important data.

References

Leave a Comment