Diff Between /dev/zero & /dev/null
As I would like to know the difference between
cp /dev/zero /var/tmp/testfile
cp /dev/null /var/tmp/testfile
with ref of the starving the system of its resources
/dev/zero provides as many ASCII null characters as read from it. The characters returned are 0x00, not the letter 0. Any writes to /dev/zero are successful, with no other side effects.
/dev/null can not be read from - any reads will return an EOF.
Now, why would you want to starve the system of its resources? This sounds suspiciously like hacking to me, which is not acceptable at LQ.
/dev/null is a sink. It is commonly used to redirect stderr to. In a cron script, you can't write to the console so you would redirect both stdout and stderr to /dev/null.
/dev/zero is a source of 0 bytes. You can use it when creating a zeroed out file, which can then be used to create a filesystem on:
dd if=/dev/zero of=imagefile bs=512 count=$((2*1024*64))
Now you have an image file you can mount using the loopback device:
sudo mount -t ext3 image.img mountdir/ -o loop
sudo chown username:username mountdir
sudo chmod 007 mountdir
Sorry Iball, you posted your message first, and I was too dense to notice the potential hacking aspect of the question.
Here is what I would do to achieve the same result under Solaris
OTOH "cp /dev/null ..." would create an empty file. No big deal.
|All times are GMT -5. The time now is 07:53 AM.|