Skip to content

/dev/null is a weird file #10

Closed
Closed

Description

That's precisely what stat says:

localhost ~ # stat /dev/null
  File: ‘/dev/null’
  Size: 0               Blocks: 0          IO Block: 512    weird file
Device: 0h/0d   Inode: 0           Links: 0
Access: (0000/?---------)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 1970-01-01 00:00:00.000000000 +0000
Modify: 1970-01-01 00:00:00.000000000 +0000
Change: 1970-01-01 00:00:00.000000000 +0000
 Birth: -

And it's causing problems with some programs (I don't remember what exactly was tripped by this in original userland, but I'm trying to run gentoo userland, and emerge fails sanity checks due to this).

Additionally, it appears there's no way to modify /dev - it always results in Operation not permitted.

Activity

  1. jpyper commented on Apr 7, 2016

    @jpyper

    Maybe the whole idea behind the Linux/Ubuntu subsystem hasn't been fully implemented yet. The UNIX philosophy is that EVERYTHING is a file. For example, /dev/null is a virtual device file. This means that nothing, is something, and that something is represented in userland as a file.

    On my Debian system, I get the following:

    john@phobos:~$ stat /dev/null
    File: '/dev/null'
    Size: 0 Blocks: 0 IO Block: 4096 character special file
    Device: 6h/6d Inode: 1037 Links: 1 Device type: 1,3
    Access: (0666/crw-rw-rw-) Uid: ( 0/ root) Gid: ( 0/ root)
    Access: 2016-04-06 20:33:12.884276144 -0700
    Modify: 2016-04-06 20:33:12.884276144 -0700
    Change: 2016-04-06 20:33:12.884276144 -0700
    Birth: -

    It looks like the Ubuntu subsystem doesn't see /dev/null as a "character special file" which I would think would redirect to >NUL on Windows.

  2. jernejs commented on Apr 7, 2016

    @jernejs
    Author

    /dev/null should be a character device with major 1 and minor 3, but it isn't in lxss, so tests like this fail:

    [ -c /dev/null ] || echo broken
    
  3. poizan42 commented on Apr 7, 2016

    @poizan42

    Shouldn't it be fine if /dev/null was simply a symlink to \Device\Null?

  4. thanosk commented on Apr 7, 2016

    @thanosk

    One side-effect of this breaks sshd (openssh-server), as also mentioned here: MicrosoftDocs/WSL#17

  5. russalex commented on Apr 11, 2016

    @russalex
    Contributor

    The weird file is a known issue and something we intend to fix. It is currently on our backlog.

  6. mjgardner commented on Apr 19, 2016

    @mjgardner

    Another side-effect: I can't build a different version of Perl, either manually or using the perlbrew package, because its configure script checks for /dev/null's usability.

  7. added 3 commits that reference this issue on Mar 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions