When you are writing complex bash scripts, you frequently use the standard pipe character (|) to pass the output of one command directly into the input of another command. However, this standard pipe is strictly linear and temporary; it only exists for the exact millisecond the two commands are running. If you need two completely independent, long-running processes (like a Python data scraper and a C++ database ingester) to continuously communicate with each other in real-time, you cannot use a standard pipe. You must create a permanent, physical conduit on the hard drive using the mkfifo command.
What is a Named Pipe (FIFO)?
The mkfifo command creates a “Named Pipe,” which is also technically known as a FIFO (First-In, First-Out) special file. To the human eye, it looks exactly like a standard text file sitting in a directory. However, it takes up absolutely zero bytes of storage space on the hard drive. It is a pure, virtual memory tunnel managed directly by the Linux kernel.
Creating and Using a Named Pipe
To create the tunnel, simply type the command followed by the name you want to give the file:
mkfifo /tmp/data_tunnel
If you run ls -l /tmp/data_tunnel, you will notice the file permissions begin with a highly specific p (e.g., prw-r--r--), indicating it is a pipe, not a standard file.
Now, you can demonstrate the incredible power of Inter-Process Communication (IPC). Open two completely separate terminal windows.
In Terminal A, command a process to continuously write data into the pipe:
echo "Critical System Alert: Overheating" > /tmp/data_tunnel
The moment you press Enter, Terminal A will completely freeze. It hangs because the kernel enforces strict synchronization: the writer cannot push data into the pipe until a reader is physically attached to the other side to pull the data out.
In Terminal B, attach a reader to pull data out of the pipe:
cat /tmp/data_tunnel
The exact millisecond you press Enter in Terminal B, the text instantly teleports across the virtual tunnel and prints to the screen. Terminal A instantly unfreezes, realizing its data was successfully delivered.
This allows you to decouple your architecture. You can have a logging script constantly appending data into /tmp/data_tunnel, and hours later, you can spin up an analytics script to attach to the pipe and consume the data stream without ever touching the physical hard drive platter.