In: Computer Science
What are the similarities and the differences between Linux files and pipes
Everything in Linux can be considered a file, but the main difference between a file and a pipe is that a pipe is a special instance of a file that has no contents on the filesystem.
A documentation from man fifo says that:
"A FIFO special file (a named pipe) is similar to a pipe, except that it is accessed as part of the filesystem. It can be opened by multiple processes for reading or writing. When processes are exchanging data via the FIFO, the kernel passes all data internally without writing it to the filesystem. Thus, the FIFO special file has no contents on the filesystem; the filesystem entry merely serves as a reference point so that processes can access the pipe using a name in the filesystem.
The kernel maintains exactly one pipe object for each FIFO special file that is opened by at least one process. The FIFO must be opened on both ends (reading and writing) before data can be passed. Normally, opening the FIFO blocks until the other end is opened also."
This means that the pipe does not occupy any space until and unless a process reads/writes some data to it.