ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
what is /dev/null ??? i know that it is a special file in Unix O/S.. for exactly which device is it?? and i need to know why it is called as NUll? does that file contain 0bytes or something (?)
In Unix-like operating systems, /dev/null or the null device is a special file that discards all data written to it, and provides no data to any process that reads from it. In Unix programmer jargon, it may also be called the bit bucket or black hole.
The null device is typically used for disposing of unwanted output streams of a process, or as a convenient empty file for input streams. This is usually done by redirection.
This entity is a common inspiration for technical jargon expressions and metaphors by Unix programmers, e.g. "please send complaints to /dev/null" or "my mail got archived in /dev/null".
The null device is also a favorite subject of technical jokes, such as warning users that the system's /dev/null is already 98% full. The April Fool's, 1995 issue of the German magazine c't reported on an enhanced /dev/null chip that would efficiently dispose of the incoming data by converting it to flicker on an internal glowing LED.
The (roughly) equivalent DOS device is NUL. Under classic Amiga operating systems, the device's name is NIL:.
so does this device contain 0 bytes ? is it a file that does not have any i-node information??
and can you call /dev/null as a special file which is related to "I/O devices"??
It's a "virtual" or "pseudo" file. It's not a real file on disk or whatever, the kernel makes it appear as a file, and makes it behave as a file that's always empty. It's not a device, and there's no device associated with it. It behaves just like a normal file, except that it will always be empty, no matter what you may have written to it.
Originally posted by sachitha so does this device contain 0 bytes ? is it a file that does not have any i-node information??
and can you call /dev/null as a special file which is related to "I/O devices"??
In UNIX/Linux everything's a file. There are regular files, there are special files. Directories and devices are examples of special files. They can (mostly) all be read and written, subject to the appropriate permissions; that's the way UNIX was designed to keep things simple and orthogonal. /dev/null is, as has been stated, simply a "bit bucket" to dump unwanted stuff into. If you wc it you'll get an answer of 0, so in that respect, yes, it's "empty". There's also a /dev/zero that is infinitely "full" of zeros (so don't wc it!) - useful if you want to overwrite, say, a floppy disk.
Incidentally, all files have an inode associated with them, that's the way the filesystem works.
Last edited by eddiebaby1023; 08-07-2005 at 05:27 AM.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.