I don't know what you are trying to achieve so I can only describe what your command is actually doing.
dd if=/dev/zero
You are reading from a special device which returns an infinite number of zero (or NUL) bytes.
of=/EMPTY
You are creating a new file using the above (infinite) input.
bs=1M
You read and write the infinite data stream in megabyte blocks. You should never do such a thing as you will probably fill up the filesystem and many tools can't cope with such situations. While the ext4 filesystem gets effectively filled up and the command ends, a compressed filesystem is able to compress the stream of zero bytes aggressively.
| true
This is nonsense, as the dd
with of=
doesn't have any output. You probably meant || true
to neutralize the status code of dd
but that's not very useful anyway, as individual command failures don't kill the whole script.
One typical use of dd if=/dev/zero
is to zero out the whole device, such as /dev/sdb
. As noted in another answer, you may want to use shred
instead. In both cases you want to refer to the whole system partitions presented in the system as block devices, not the individual files (that may not exist any more). There are lots of books and online resources on linux block devices and manual pages of shred
and dd
are also very useful.
When you delete a file, its blocks are immediately available. You don't need to perform any black magic. If you want to wipe out the contents of a file to prevent forensic techniques, just use schred --delete
to remove the file instead of a normal delete. Wiping out blocks of an already deleted file is not so easy and you cannot simply rely on creating a large empty file. You would need a specialized filesystem specific tool to do it securely.
strace
ortruss
and see what is happening behind the scenes?~/EMPTY
instead of/EMPTY
.