WARNING: The following is a PERSONAL brief of part of the second chapter of the book How Linux Works: what every superuser should know by Brian Ward
Linix device files are in the
/dev directory. A device can be identified using the
ls -l command.
An extract of the output from the command line
ls -l /dev is shown below,
crw-rw----+ 1 root cdrom 21, 1 Sep 6 01:23 sg1 lrwxrwxrwx 1 root root 8 Sep 6 01:23 shm -> /run/shm crw------- 1 root root 10, 231 Sep 6 01:23 snapshot drwxr-xr-x 3 root root 220 Sep 6 01:23 snd brw-rw----+ 1 root cdrom 11, 0 Sep 6 01:23 sr0 srw-rw-rw- 1 root root 0 Sep 6 01:23 log prw-r--r-- 1 root root 0 Sep 6 01:23 gpmdata
The first column is a code which indicates the type of ‘file’ (the first character) and permissions (the other nine characters).
If the first character is
s, then the file is a device. These letters stand for block, character, pipe, and socket, respectively:
- block: Programs access data in a block device in.
- character: Character devices work with data streams.
- pipe: are like character devices, but there is another process at the other end of the I/O stream instead of a kernel driver.
- socket: are special-purpose I/O files offering a type of network interface.
The numbers before the dates in the first two lines of the previous listing are the major and minor device numbers that help the kernel identify the device.