When you are architecting a complex, multi-process bash architecture on a Linux server, passing massive data payloads between two independent scripts using standard temporary files is highly inefficient. It forces the kernel to physically write the data to the hard drive, consuming IO cycles and disk space. To force two independent processes to mathematically communicate with each other entirely within the system’s volatile RAM, you must establish a named pipe using the mkfifo command.
Understanding the Named Pipe Architecture
The mkfifo command algorithmically generates a specialized file node on the file system known as a FIFO (First In, First Out). Despite appearing as a physical file in your directory structure, a FIFO takes up zero bytes on the hard drive. It acts as a direct, memory-based conduit. When Process A writes to the FIFO, the kernel blocks the process until Process B connects to the exact same FIFO and reads the data stream.
Executing the FIFO Matrix
To initialize a pristine named pipe, open your terminal and type:
mkfifo /tmp/data_conduit
The exact millisecond you press Enter, the kernel creates the FIFO node. If you run ls -l /tmp/data_conduit, you will see the permissions block begins with a rigid p (e.g., prw-rw-r--), mathematically proving it is a pipe, not a standard file.
Executing the Inter-Process Communication
You must now execute two separate processes to prove the conduit works.
- Open Terminal Window 1. This will act as the data transmitter. Execute a continuous stream of data into the FIFO:
ping google.com > /tmp/data_conduit - Notice that Terminal 1 instantly hangs. It is blocked by the kernel because nothing is currently reading the data.
- Open Terminal Window 2. This will act as the data receiver. Execute a read command on the identical FIFO:
cat /tmp/data_conduit
The exact millisecond Terminal 2 connects, the kernel violently unblocks Terminal 1. The data payload (the ping results) is instantly streamed from Terminal 1, through the RAM-based FIFO, and dumped directly onto the screen of Terminal 2, without a single byte ever touching the physical hard drive.