LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-22-2010, 03:53 AM   #1
crahuldba@gmail.com
Member
 
Registered: Apr 2010
Posts: 51

Rep: Reputation: 2
What is /dev/null /dev/zero


Hello Friends
Can any one explain thi use of /dev/null and /dev/zero and what is the deference in them.
please answer
i face this question in interview
Thanks & Regards
Rahul
 
Old 10-22-2010, 03:58 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387
Hi,

A quick internet search would have given you the answer:

- /dev/zero
- /dev/null

In short: /dev/null is a "black hole" all put in is gone. /dev/zero generates zero's.

Hope this helps.
 
Old 10-22-2010, 04:33 AM   #3
aries_baluyot
Member
 
Registered: Oct 2010
Location: India
Distribution: Mandriva, Suse, Ubuntu, Centos, Maemo, Omnia Xp
Posts: 86

Rep: Reputation: -11
Quote:
Originally Posted by crahuldba@gmail.com View Post
Hello Friends
Can any one explain thi use of /dev/null and /dev/zero and what is the deference in them.
please answer
i face this question in interview
Thanks & Regards
Rahul
http://digg.com/news/technology/dev_...The_Difference
 
Old 10-22-2010, 05:09 AM   #4
aus9
LQ Guru
 
Registered: Oct 2003
Posts: 5,124

Rep: Reputation: Disabled
hi

can I suggest you ask the mods if you can change your username from x at gmail dot com to something else so you get less spam

Yes I know gmail as a spam filter.

regards
 
Old 10-22-2010, 05:13 AM   #5
ionrivera
Member
 
Registered: May 2010
Distribution: Debian, RHEL, AIX, Solaris, HP-UX
Posts: 61

Rep: Reputation: 4
Wink

Real world example:

/dev/null:

If I want to discard all data written to largelogfile.log to free-up some space:
Code:
cat /dev/null > /var/log/largelogfile.log
If my script produces error, and wants to hide error message from stderr.
Code:
./myscript 2> /dev/null
If I want to redirect output to multiple files and want to hide stdout to screen:
Code:
echo YES|tee file1 file2 file3> /dev/null
/dev/zero:

If I want to add 100MB more swap memory:
Code:
dd if=/dev/zero of=/extra-swap bs=10000 count=10000 
#this will create 100MB storage file

mkswap /extra-swap 
#generate swap signature

swapon /extra-swap 
#this will enable /swap-extra file as a new extra swap memory
If I want to completely destroy my MBR:
Code:
dd if=/dev/zero of=/dev/sda bs=512 count=1

Last edited by ionrivera; 10-26-2010 at 02:04 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 01:46 PM
LXer: /dev/null And /dev/zero On Linux And Unix: What's The Difference? LXer Syndicated Linux News 0 04-29-2009 11:50 AM
Startx Permission problems on /dev/null and /dev/mem on freshly compiled 2.6.22.1 Eric_Cartman Linux - Kernel 2 09-09-2007 02:42 AM
What is meant by " file > /dev/null 2>&1 </dev/null " attockonian Linux - Newbie 5 06-30-2006 11:51 PM
mv c:\WINDOWS /dev/null; mount /dev/hda treehead LinuxQuestions.org Member Intro 5 10-19-2004 09:53 AM


All times are GMT -5. The time now is 04:21 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration