Would you explain how to erase data from device connected through USB in terminal
2 Answers
Ubuntu / Linux doesn't make a difference between a built-in drive or an external drive, e.g. a USB pen drive.
Open a terminal, navigate to the drive (usually mounted under /media/your_user_name and use either the rm command to delete single files or rm -r directory_name to delete a directory recursively. Or use one of the mkfs commands (e.g. mkfs.fat) for formatting the drive. Remember that for the latter the stick has to be not mounted.
- 1,769
There are (at least) two (2) commonly-used utilities for erasing data from a drive:
ddshred
In the examples below, the partition to be wiped is called sdX1, where X is typically a, b, c, ... etc. You can learn this partition name from running the command lsblk --fs when the USB device to be erased is "plugged in" to your system.
1. Using dd (ref man dd):
sudo dd if=/dev/zero of=/dev/sdX1 bs=1M
- The "input file" (
if) is/dev/zero- a linux pseudo-device of null bytes - The "output file" (
of) is the partition on your drive you wish to erase; i.e./dev/sdX1 - The "block size" (
bs) is the size of blocks to be written (larger block sizes usually translate to quicker results).
2. Using shred (ref man shred):
sudo shred /dev/sdX1
/dev/sdX1: the "file" to be shredded
- 698