cancel
Showing results for 
Search instead for 
Did you mean: 

/dev/null

himacs
Super Advisor

/dev/null

Can anyone please tell me wwhy /dev/null used?


Regards,
himacs
4 REPLIES
Ivan Ferreira
Honored Contributor

Re: /dev/null

The /dev/null special file is used when you want to discard information. For example:

ls -la 2> /dev/null

This redirection will discard error messages. You won't see it on the screen.

Also, you can do some performance test using /dev/null, for example:

dd if=/dev/rdisk/dsk0c of=/dev/null bs=8k

With this command you can determine how fast can you read from a disk device.
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
Venkatesh BL
Honored Contributor

Re: /dev/null

There is a wiki page for almost everything these days!....
Check this one: http://en.wikipedia.org/wiki/Data_sink
Rob Leadbeater
Honored Contributor

Re: /dev/null

To make your backups go really quick ... ;-)

Cheers,

Rob
Martin Moore
HPE Pro

Re: /dev/null

One thing to be aware of is that if /dev/null accidentally gets removed (which I've seen happen) it can cause some odd effects. There are a number of scripts that redirect error output to /dev/null, as shown in an earlier reply. However, if /dev/null doesn't exist, a command like "cat foo 2> /dev/null" will recreate /dev/null...but as a regular file, not a data sink! This file will gradually accumulate junk and possibly fill up the root filesystem eventually.

But even worse, if /dev/null is a regular file and you try to build the kernel with doconfig, the build will fail with some very strange error messages. You can always check for this possibility with the command "file /dev/null". If it doesn't show up as a character special device file, then you should remove it and recreate it properly (cd /dev; rm null; ./MAKEDEV null).

Martin
I work for HP
A quick resolution to technical issues for your HP Enterprise products is just a click away HP Support Center Knowledge-base
See Self Help Post for more details