Diff Between /dev/zero & /dev/null
Hi
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 Thanks Rajan |
(From Wikipedia)
/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. --Ian |
/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)) /sbin/mkfs.ext3 imagefile 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. |
Quote:
Here is what I would do to achieve the same result under Solaris Code:
mkfile -n $((2*1024*64*512)) imagefile Code:
mkfile -n $((2*1024*64*512)) imagefile OTOH "cp /dev/null ..." would create an empty file. No big deal. |
Quote:
|
All times are GMT -5. The time now is 02:22 PM. |