4.5.8 Device files
Device files refer to physical or virtual devices on your system, such as your
hard disk, video card, screen, or keyboard. An example of a virtual device is
the console, represented by /dev/console.
There are two types of devices:
You can read and write device files, though the file may well contain binary
data which may be an incomprehensible-to-humans gibberish. Writing data
directly to these files is sometimes useful for the troubleshooting of hardware
connections. For example, you can dump a text file to the printer device
/dev/lp0 or send modem commands to the appropriate serial port
/dev/ttyS0. But, unless this is done carefully, it may cause a
major disaster. So be cautious.
/dev/null is a special device file that discards anything you
write to it. If you don't want something, throw it in
It's essentially a bottomless pit. If you read
get an end-of-file (EOF) character immediately.
/dev/zero is similar, only if you read from it you get the
\0 character (not the same as the number zero ASCII). See Dummy files, Section 8.6.34.
18.104.22.168 Device node number
The device node number are displayed by executing
$ ls -l /dev/hda /dev/ttyS0 /dev/zero
brw-rw---- 1 root disk 3, 0 Mar 14 2002 /dev/hda
crw-rw---- 1 root dialout 4, 64 Nov 15 09:51 /dev/ttyS0
crw-rw-rw- 1 root root 1, 5 Aug 31 03:03 /dev/zero
/dev/hda has the major device number 3 and the minor device number
0. This is read/write accessible by the user who belongs to disk
/dev/ttyS0 has the major device number 4 and the minor device
number 64. This is read/write accessible by the user who belongs to
dialout group, and
/dev/zero has the major device number 1 and the minor device
number 5. This is read/write accessible by anyone.
In the older system, the installation process creates the device nodes using
/sbin/MAKEDEV command. See
In the newer system, the filesystem under in the
automatically populated by the device filesystem similar to the