A device is a piece of equipment for communicating data or storing data - examples are DVD drives, printers and keyboards. Linux provides access to a device by associating one or more special files with a device. These special files can be found in the /dev directory.
Putting it into Practice:
|You can always find out what devices are attached to your system by typing ls -l /dev/ at the prompt|
|What kind of files do you see in /dev/?|
For example, you can print a file on printer 1 by sending it to the special file /dev/lp1 Usually, operations such as these are handled by high-level system programs, rather than user-level operations.
When a program performs on operation on a special file, such as asking the kernel to read the file, this operation is typically carried out by a device driver associated with that special file. The device driver is a bit like an interpreter - it takes file-oriented operations in linux and translates them into instructions that the device can understand. Special files, like other files, have permissions attached to them.
There are two main types of devices: character devices and block devices. Character devices produce and/or consume a stream of characters. A keyboard produces characters, a printer consumes characters - so both are character devices. Block devices are used chiefly to store data. Two examples of a block device are disks and tapes.