Operating System - Linux
1827782 Members
2812 Online
109969 Solutions
New Discussion

what is the /dev/zero at all?

 
SOLVED
Go to solution

what is the /dev/zero at all?

thanks, i do not know what it is.

Best Regards,
Frederick
frederick van targero
7 REPLIES 7
Balaji N
Honored Contributor
Solution

Re: what is the /dev/zero at all?

man zero.

it is the same as /dev/null.

++++++++++++++++++++++++++++++
DESCRIPTION
Data written on a null or zero special file is discarded.

Reads from the null special file always return end of file, whereas
reads from zero always return \0 characters.

null and zero are typically created by:

mknod -m 666 /dev/null c 1 3
mknod -m 666 /dev/zero c 1 5
chown root:mem /dev/null /dev/zero

NOTES
If these devices are not writable and readable for all users, many pro-
grams will act strange.
++++++++++++++++++++++++++++++

-balaji (and i love answering ur questions. for i get easy bunnies)
Its Always Important To Know, What People Think Of You. Then, Of Course, You Surprise Them By Giving More.
Balaji N
Honored Contributor

Re: what is the /dev/zero at all?

a small correction. they are similar files rather than telling the same.

-balaji
Its Always Important To Know, What People Think Of You. Then, Of Course, You Surprise Them By Giving More.
Michael Steele_2
Honored Contributor

Re: what is the /dev/zero at all?

/dev/zero is used to sanitize your disk. If you are returning leased equipment or even throwing away a computer then some people worry about an invasion of privacy from scavengers who pull confidential information off of these disks.

dd if=/dev/zero if=/dev/dsk/cXtYdZ bs=32
Support Fatherhood - Stop Family Law
Sergejs Svitnevs
Honored Contributor

Re: what is the /dev/zero at all?

Think of /dev/null as a "black hole". It is the nearest equivalent to a write-only file. Everything written to it disappears forever. Attempts to read or output from it result in nothing. Nevertheless, /dev/null can be quite useful from both the command line and in scripts.

Regards,
Sergejs
Stuart Browne
Honored Contributor

Re: what is the /dev/zero at all?

What's been said so far is right on the money.

Some classic examples of what they are used for:

/dev/null

some.application 2>/dev/null

To redirect errors to the bit-bucket, so you don't see them on the screen.

/dev/zero

dd if=/dev/zero of=some.file bs=1024b count=1024

Create a completely empty 1MB file. Creating test files to do work on is not all that unusual. Some times people use this to check if their file-system can create large-files (greater than 2GB).

It can also be used to clean a disk (whether it be a floppy or a hard-disk) as mentioned in an earlier post.

anyway.. hope this clears things up a bit.
One long-haired git at your service...
Donald Kok
Respected Contributor

Re: what is the /dev/zero at all?

Hi,

In my opinion /dev/zero is different than /dev/nul.

/dev/zero can produce an (virtual) endless stream of zero's, where /dev/nul is just a bitbucket.

Greetzz
Donald
My systems are 100% Murphy Compliant. Guaranteed!!!
Stuart Browne
Honored Contributor

Re: what is the /dev/zero at all?

*points to Balaji's second post* yup..
One long-haired git at your service...