Linux Know-How provides a collection of introductory texts on often needed Linux skills.

Device Files

Devices appear as files in the directory /dev. They can be read, or written to, if you have the permission to do so. The listing of the file reveals some important details about the device, for example:

ls -l /dev/ttyS3

on my system produces the following output:

crwxr-xr-x 1 root tty 4, 67 Mar 13 22:59 ttyS3

The initial "c" indicates a character device. "b" would mean "block device", "p"=FIFO device, "u"=unbuffered character device, "d"=directory, "l"=symbolic link. The numbers "4, 67" mean that the device major number is 4 and the minor number is 67. To make some devices usable to all users on your system, you may need to set the proper permissions. For example:

ls -l /dev/usb/scanner0

chmod 666 /dev/usb/scanner0

Here is a list of some common devices:

/dev/ttyS0 - the first serial port. The mouse is typically connected here.

/dev/ttyS1 - the second serial port. This may well be the device to which your modem is connected.

/dev/ttyS2 and /dev/ttyS3 the third and fourth serial port (typically not present, but your internal modem may well be configured as one of these).

/dev/modem - the serial modem. In the typical case, a symbolic link to /dev/ttyS1, /dev/ttyS2, /dev/ttyS3 or /dev/ttyS0, depending to which serial port your modem is connected.

/dev/mouse - mouse. In the typical case, a symbolic link to /dev/ttyS0 or similar (see above), depending to which serial port your mouse is connected.

/dev/lp0 - printer on the first parallel port. That's where normally printers are connected.

/dev/lp1 - printer on the second parallel port (typically not present).

/dev/fd0 - first floppy disk drive (almost always present).

/dev/fd0H1440 - driver for the first floppy drive in the high-density mode (1440 kB). Generally, this (or a driver with a device with a similar descriptive name) is invoked when formatting a floppy drive to a particular density. Slackware also comes with drivers that allow for formatting a 3.5" diskette with up to 1.7MB of space. Red Hat and Mandrake do not contain these device drivers files by default.

/dev/fd1 - second floppy disk drive.

/dev/hda - first IDE hard drive (whole drive). Most hard drives on IBM-compatibile PCs are IDE.

/dev/hdb - second IDE hard drive (whole drive). On many computers, the IDE cdrom drive is attached here.

/dev/hdc - third IDE drive (whole drive). On many computers, the IDE cdrom drive is attached here.

/dev/cdrom - a symbolic link to the appropriate drive interface, typically /dev/hdc or /dev/hdb (a CDROM) or /dev/scd0 (a CD-R/RW writer).

/dev/hda1 - the first partition on the first IDE hard drive. /dev/hda2 is the second partition on the first IDE hard drive. As one could guess, /dev/hdd8 would be the eight partition on the fourth IDE hard drive.

/dev/tty1 - the first text console. /dev/tty2 is the second text console, etc.

/dev/dsp - digital audio, i.e., the sound card. "dsp" stands for "digital signal processing".

/dev/sndstat - do cat /dev/sndstat to learn about the status of your sound devices.

/dev/null - used when you want to send output into oblivion.

/dev/random - used to read pseudo-random numbers. Do cat /dev/random to display garbage-looking characters on your screen. There is also /dev/urandom to generate lower-quality random sequences.

/dev/sda -the first SCSI drive (whole drive). On a home machine, you are unlikely to have any SCSI drives (expensive).

/dev/sdb - the second scsi drive ("sdc" is the third scsi drive, etc. There can be many scsi drive on a system).

/dev/sda1 - the first partition on the first scsi drive.

/dev/sr0 - the first scsi CD drive (sometimes called /dev/scd0). If you have an ATAPI CD writer, it will also be likely here.

/dev/sr1-is the second scsi CD drive (sometimes called /dev/scd1), (/dev/sr2 is the third scsi CD drive, etc. There can be many scsi CD drives on the system).

/dev/usb/scanner0 - a usb scanner. Try: less /usr/src/linux/Documentation/usb/scanner.txt for an info on scanner configuration from scratch.

For more info try:

less /usr/src/linux/Documentation/devices.txt


As explained in /usr/src/linux/Documentation/devices.txt, I may need to create some symbolic links to device files locally to configure my system. This is merely a tabulation of existing practice, and does not constitute a recommendation. However, if the links exist, they should have the following uses:

/dev/mouse Current mouse port***

/dev/tape Current tape device

/dev/cdrom Current CD-ROM device***

/dev/cdwriter Current CD-writer device (but my RedHat have /dev/cdrecorder)

/dev/scanner Current scanner device

/dev/modem Current dialout (modem) port***

/dev/root Current root file system

/dev/swap Current swap device

The *** mark the symbolic links that are surely present on my Mandrake system. For example, if having problems with mouse I would do something like (as root):

ls -l /dev/mouse

[see if the mouse device is present and where it points]

ln -s /dev/ttyS0 /dev/mouse

[create a symbolic link so that /dev/mouse points to the first serial port]

For SCSI (and ATAPI) devices, /dev/tape and /dev/cdrom should point to the ``cooked'' devices (/dev/st* and /dev/sr*, respectively), whereas /dev/cdwriter and /dev/scanner should point to the appropriate generic SCSI devices (/dev/sg*).

Non-transient sockets and named pipes may exist in /dev. Common entries are:

/dev/printer socket lpd local socket

/dev/log socket syslog local socket

/dev/gpmdata socket gpm mouse multiplexer

Last Update: 2010-12-16