LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-04-2005, 10:24 AM   #1
sachitha
Member
 
Registered: Aug 2003
Location: Sri Lanka
Distribution: Redhat 9.0
Posts: 104

Rep: Reputation: 15
/dev/null


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 (?)
 
Old 08-04-2005, 10:30 AM   #2
Boffy
Member
 
Registered: Jul 2003
Location: Durham, UK
Distribution: Ubuntu 8.04
Posts: 419

Rep: Reputation: 30
http://en.wikipedia.org/wiki/Dev/null:
Quote:
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:.
 
Old 08-05-2005, 12:39 AM   #3
sachitha
Member
 
Registered: Aug 2003
Location: Sri Lanka
Distribution: Redhat 9.0
Posts: 104

Original Poster
Rep: Reputation: 15
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"??
 
Old 08-05-2005, 07:36 AM   #4
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
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.

Last edited by Hko; 08-05-2005 at 07:37 AM.
 
Old 08-07-2005, 05:25 AM   #5
eddiebaby1023
Member
 
Registered: May 2005
Posts: 378

Rep: Reputation: 33
Quote:
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.
 
Old 08-07-2005, 11:25 AM   #6
exvor
Senior Member
 
Registered: Jul 2004
Location: Phoenix, Arizona
Distribution: Gentoo, LFS, Debian,Ubuntu
Posts: 1,537

Rep: Reputation: 87
cool /dev/zero (getting evil ideas)


YAY
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
What would happen if I where to cat /dev/mem > /dev/null Joey.Dale Linux - General 11 07-26-2009 12:46 PM
/dev/null linuxprogrammer Linux - Newbie 1 09-05-2005 07:07 AM
mv c:\WINDOWS /dev/null; mount /dev/hda treehead LinuxQuestions.org Member Intro 5 10-19-2004 08:53 AM
/dev/null jon_k Linux - Hardware 5 07-16-2003 02:40 PM
>/dev/null lackluster Linux - Networking 5 06-27-2002 09:54 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:00 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration