红联Linux门户
Linux帮助

/dev/zero是什么意思

发布时间:2009-10-16 10:30:27来源:红联作者:lhm1986
/dev/zero
这个是做什么用的,有人能详细的介绍一下吗。。。。在网上找了一些,可是解释的都不太详细。。。。
文章评论

共有 11 条评论

  1. xwj369606094 于 2009-10-28 09:55:27发表:

    菜鸟,不懂...

  2. prinse 于 2009-10-27 21:47:16发表:

    先把 linux 用上一段时间,你自然就会想到要用上这些设备了……

  3. tomlei 于 2009-10-22 09:35:15发表:

    谢谢楼上的前辈。学习了。。。{:3_114:}

  4. ql08421032 于 2009-10-20 17:20:51发表:

    完全看不懂阿

  5. fanhuan 于 2009-10-20 13:35:47发表:

    学习了!

  6. yangshan 于 2009-10-19 20:50:25发表:

    特殊的文件 还有很多!

  7. dragon008 于 2009-10-19 00:03:20发表:

    一般用来创建文件用的,比如说要创建一个10m的文件,就是dd if=/dev/zero of=/mnt/temp.tmp bs=1M count=10

  8. 寻路行者 于 2009-10-18 15:37:08发表:

    初学者,还没有学到那么多……

  9. luciffer 于 2009-10-16 16:18:27发表:

    zero 查英文字典意思为 0,无

  10. lhm1986 于 2009-10-16 12:46:56发表:

    谢谢。。。

  11. hsvea 于 2009-10-16 10:35:03发表:

    /dev/zero,是一个输入设备,你可你用它来初始化文件。
    /dev/zero------该设备无穷尽地提供0,可以使用任何你需要的数目----设备提供的要多的多。他可以用于向设备或文件写入字符串0。

    oracle@localhost oracle]$if=/dev/zero of=./test.txt bs=1k count=1
    oracle@localhost oracle]$ ls -l
    total 4
    -rw-r--r-- 1 oracle dba 1024 Jul 15 16:56 test.txt

    eg,

    find / -name access_log 2>/dev/null

    这样,一些诸如一些错误信息就不会显示出来。


    /dev/zero:

    In Unix-like operating systems, /dev/zero is a special file that provides as many null characters (ASCII NULL, 0x00; not ASCII character "digit zero", "0", 0x30) as are read from it. One of the typical uses is to provide a character stream for overwriting information. Another might be to generate a clean file of a certain size. Using mmap to map /dev/zero to RAM is the BSD way of implementing shared memory.

    # Initialise partition (important note: trying out this command will eradicate
    # any files that were on the partition, make sure you have a backup of any important data.)
    dd if=/dev/zero of=/dev/hda7

    # Create a large empty file called 'foobar'
    dd if=/dev/zero of=foobar count=1000 bs=1000

    Like /dev/null, /dev/zero acts as a source and sink for data. All writes to /dev/zero succeed with no other effects (the same as for /dev/null, although /dev/null is the more commonly used data sink); all reads on /dev/zero return as many NULs as characters requested.