Don't run this POSIX command. It'll attempt to wipe out your hard drive.

Well, at least don't attempt to run it with root privileges. dd is a low-level POSIX command (that includes our beloved GNU/Linux) for moving data around. It can be used for copying files, but nowadays it's usually used to write data to physical drives in a low-level fashion. E.g. it can be used to write an .iso disk image to a cd. It uses an old-fashioned option syntax with operands instead of arguments, and it's a shame that such a potentially harmful command uses an obscure syntax, further masking its destructive properties.

Breaking it down, the command says this:

  • dd: "move data around"
  • if=: "the input file is..."
  • /dev/zero: "not a file at all, but a device that outputs an unending stream of zeros"
  • of=: "and the output file is..."
  • /dev/hda: "not a file at all either, but your first physical hard disk, usually an IDE hard disk." Sometimes the hard disks are SCSI (pronounced "scuzzy") and found in /dev/sda instead.

In short, this command attempts to write a zero at every writable location on your hard drive. This is even worse than, say, just deleting the partition table, since it actually completely overwrites all the information in your hard drive with little hope of recovery. I bet even the FBI with all their gadgetry would have a hard time finding out what was in your drive if this command is successful (well, maybe not, but an average user without specialised hardware will).

There are legitimate uses of this command or small variants of it, e.g. in case you want to wipe some writable device before repartitioning and reformatting, in case that an existing partition or filesystem is broken on the device. However, such uses are very rare and there's usually a better POSIX way of doing it. Don't use dd for that. If you're using a GNU system and you really want to completely wipe a hard drive, you can use shred to do just that.

Although I have no safe means to test it, it's actually more than likely that the dd command will not complete its operation, especially if /dev/hda is mounted (i.e. the operating system currently thinks that the hard drive is a good place to read and write). There is a similar equally destructive command but not as bad, rm -rf / that attempts at a higher level of abstraction to delete your root directory. You can read about that at this external webpage, which even compares it to the command format c: in an ignominious family of operating systems that shall remain nameless.

(I don't think this writeup is particularly worthy, but I'm troubled that such a potentially harmful command is nodeshelled, the nodeshell isn't getting deleted and there's no explanation as to why this command is so bad. Won't someone please think of the n00bs!)

Log in or register to write something here or to contact authors.