Frequently Asked Question

What does it really mean that 'everything is a file' in Linux?

The phrase is a design slogan from the original Unix work at Bell Labs in 1970. Rather than inventing one API for disks, another for keyboards, another for serial lines and so on, Thompson and Ritchie made all of them look like files: you open them, read from them, write to them, and close them through the same handful of system calls. The kernel then dispatches each call to whichever driver actually implements that particular file's behaviour. Linus Torvalds has pointed out it is really "everything is a stream of bytes", which is a more honest description of the abstraction.

The practical consequence is that a program written to process a file will also work, unchanged, on keyboard input, network data, or the output of another program. Pipes, redirection, and the entire shell-utility ecosystem fall out of that one decision. The uniformity is not perfect, sockets need their own bind/accept family, some devices demand ioctl calls to do anything interesting, but it is strong enough that cat, dd, and tee happily talk to disks, terminals, pipes and USB serial ports without caring which is which.

Video

Further reading and video