Archive for July, 2008

Securely delete /home when it resides within the root filesystem

Thursday, July 31st, 2008

Here’s a way to obliterate everything in a sensitive directory if you do not have the luxury of wiping the entire disk device it resides on. It overwrites every file with random data and renames every file to a random name.

 for temp in `find /home/ -type f`; do SIZE=`du -k $temp | cut -f1`; \
    echo -n Obliterating $temp; FAILED=; dd if=/dev/urandom \
    of=$temp bs=1K count=$(($SIZE+1)) >/dev/null 2>/dev/null \
    || FAILED=1; if [ ! -z $FAILED ]; then echo ... failed; else \
    echo ... done; FNAME=`base64 /dev/urandom | tr -d '+/\r\n0-9' \
    | head -c 50`; mv $temp $FNAME;  fi  ; done