Device files

/usr/src/linux/documentation/devices.txt contains list of the devices.

/dev contains list of all devices possible. As in/proc, the files in/dev are also not regular data files. They are used as link from an application to the kernel. Devices can be accessed as would they be files:

  1. cat /dev/input/mouse0 reads from you that your mouse is alive.

  2. cat /dev/urandom > /dev/dsp reads from the random number generator and writes those to to the sound card, do not wear a headphone when typing enter.

Crtl + C ends it.

Devices belong to a user and/or group .e.g./dev/hda belongs to the group disk. If you want to access it you should therefore also be added to the group disk.

The devices have a major number defined in the kernel module. If you write a device driver (= kernel module) on your own, you have to put inside a major number. Additionally a minor number used to select a particular device (e.g fd0 or fd1).

cd /dev

ls -l shows those numbers

There are block devices and character devices that could use independently the same major number.


brw-rw---- 1 root disk 8, 0 Dec 28 10:35 sda

b block device , 8 major, 0 minor, Dec 28 10:35 creation date and time

Devices files can be static in/dev (have to be static when used during boot) or can be appear dynamically to not have an huge list that little get used

udev is included in Kernel 2.6 to create those files dynamically. It has replaced devfs in previous kernel versions. The date of the/dev files is an indication whether or not they are created dynamically.

Linurs Servernest startpage