Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What exactly does the files in /dev do? I'm having a difficult time understanding the relation between the files here, device drivers and the device.

Taking an example, what does /dev/hda do? does the hard disk driver read/write into it?

share|improve this question

No, it is created by the hard disk driver so that higher-level drivers (device mapper, filesystem, etc.) can read/write/seek/tell/open/close/ioctl it.

(Actually, they operate on the device numbers directly, but it's a close-enough abstraction.)

share|improve this answer
oh..ok. So it's the interface between the higher level drivers in the kernel (logical) and the driver for the actual device. – Traveller Jul 22 '10 at 14:00

The /dev/ filesystem provides files that act as interfaces to the actual devices. It exists to facilitate using the hardware stuff with common IO functions and to identify the hardware to the user.

So when you act on the device file the driver has code that identifies what is happening and acts on the hardware to do what you asked.

You have character and block device files. Character devices write/read char by char (keyboards, mouses, modems, etc...) and block devices write/read in chunks of data. You also have some pseudo devices like /dev/null and /dev/random that are not associated with any hardware but work like one.

share|improve this answer
Ok. Let's say I'm writing something to a disk. The application prog/kernel writes something to the /dev/hda (or whichever) which in turn is read by the driver, interpreted and sent to the particular hard disk? – Traveller Jul 22 '10 at 13:55
In a very summarized way, it is. It is more complex than that though and I recommend you reading a book on unix/linux kernel internals to see how they interact. The comments on this code can show you an example of use of the dev filesystem. – coredump Jul 22 '10 at 14:41
Thanks a lot...appreciate it – Traveller Jul 22 '10 at 15:25

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.