-
-
Save hctilg/34c93ab990740bf54c485d9e485cbe0a to your computer and use it in GitHub Desktop.
**Secure Data Erasure Script (Bash)** This Bash script securely erases data from a specified device with random data, ensuring irrecoverability. Use with caution.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Check if the script is run with superuser privileges | |
if [ "$EUID" -ne 0 ]; then | |
echo "Please run this script as root (sudo)." | |
exit 1 | |
fi | |
# Prompt the user for the target devices | |
read -p "Enter the target devices (e.g., /dev/sdX /dev/sdY): " target_devices | |
# Iterate through the space-separated list of target devices | |
for device in $target_devices; do | |
# Check if the device exists | |
if [ ! -e "$device" ]; then | |
echo "Device $device does not exist." | |
continue | |
fi | |
# Overwrite with random data | |
echo "Erasing $device..." | |
dd if=/dev/urandom of="$device" bs=4M status=progress | |
echo "Finished erasing $device." | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment