<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://lms.onnocenter.or.id/wiki/index.php?action=history&amp;feed=atom&amp;title=Mkfifo%3A_how_it_works_%28en%29</id>
	<title>Mkfifo: how it works (en) - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://lms.onnocenter.or.id/wiki/index.php?action=history&amp;feed=atom&amp;title=Mkfifo%3A_how_it_works_%28en%29"/>
	<link rel="alternate" type="text/html" href="https://lms.onnocenter.or.id/wiki/index.php?title=Mkfifo:_how_it_works_(en)&amp;action=history"/>
	<updated>2026-04-28T04:51:27Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>https://lms.onnocenter.or.id/wiki/index.php?title=Mkfifo:_how_it_works_(en)&amp;diff=71010&amp;oldid=prev</id>
		<title>Unknown user: Created page with &quot;&#039;&#039;&#039;mkfifo&#039;&#039;&#039; stands for &#039;&#039;&#039;make first-in-first-out&#039;&#039;&#039;. It is a command in Unix-based operating systems like Ubuntu that is used to create a *named pipe*. A pipe is an inter-pr...&quot;</title>
		<link rel="alternate" type="text/html" href="https://lms.onnocenter.or.id/wiki/index.php?title=Mkfifo:_how_it_works_(en)&amp;diff=71010&amp;oldid=prev"/>
		<updated>2024-10-20T21:30:43Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;&amp;#039;&amp;#039;&amp;#039;mkfifo&amp;#039;&amp;#039;&amp;#039; stands for &amp;#039;&amp;#039;&amp;#039;make first-in-first-out&amp;#039;&amp;#039;&amp;#039;. It is a command in Unix-based operating systems like Ubuntu that is used to create a *named pipe*. A pipe is an inter-pr...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;#039;&amp;#039;&amp;#039;mkfifo&amp;#039;&amp;#039;&amp;#039; stands for &amp;#039;&amp;#039;&amp;#039;make first-in-first-out&amp;#039;&amp;#039;&amp;#039;. It is a command in Unix-based operating systems like Ubuntu that is used to create a *named pipe*. A pipe is an inter-process communication mechanism that allows one process to write data into the pipe while another process reads that data.&lt;br /&gt;
&lt;br /&gt;
==Difference between `mkfifo` and a regular pipe:==&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Regular pipe:&amp;#039;&amp;#039;&amp;#039; Created dynamically when two processes communicate and disappears once the communication ends.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Named pipe:&amp;#039;&amp;#039;&amp;#039; Permanently created in the file system, allowing different processes to access it at any time as long as the pipe exists.&lt;br /&gt;
&lt;br /&gt;
==Why Use `mkfifo`?==&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Inter-process communication:&amp;#039;&amp;#039;&amp;#039; Ideal for connecting two or more independently running programs.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Synchronization:&amp;#039;&amp;#039;&amp;#039; Can be used to synchronize activities between processes.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Gradual data processing:&amp;#039;&amp;#039;&amp;#039; Data can be written and read incrementally, allowing for more efficient data processing.&lt;br /&gt;
&lt;br /&gt;
==How to Use `mkfifo`==&lt;br /&gt;
&lt;br /&gt;
===Creating a named pipe:===&lt;br /&gt;
&lt;br /&gt;
 mkfifo pipe_name&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
 mkfifo mypipe&lt;br /&gt;
&lt;br /&gt;
The above command creates a named pipe called `mypipe` in the current directory.&lt;br /&gt;
&lt;br /&gt;
===Accessing a named pipe:===&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Reading from the named pipe:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt; pipe_name&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Writing to the named pipe:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
 echo &amp;quot;Hello&amp;quot; &amp;gt; pipe_name&lt;br /&gt;
&lt;br /&gt;
===Usage Example:===&lt;br /&gt;
&lt;br /&gt;
Suppose we have two scripts:&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Script 1 (writer):&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
  #!/bin/bash&lt;br /&gt;
  while true; do&lt;br /&gt;
      echo &amp;quot;Data from script 1&amp;quot; &amp;gt; mypipe&lt;br /&gt;
      sleep 1&lt;br /&gt;
  done&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Script 2 (reader):&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
  #!/bin/bash&lt;br /&gt;
  while true; do&lt;br /&gt;
      read line &amp;lt; mypipe&lt;br /&gt;
      echo &amp;quot;Received data: $line&amp;quot;&lt;br /&gt;
  done&lt;br /&gt;
&lt;br /&gt;
Script 1 will continuously write data to `mypipe` every second, while script 2 will continuously read data from `mypipe` and display it on the screen.&lt;br /&gt;
&lt;br /&gt;
==Additional `mkfifo` Options==&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;`-m mode`:&amp;#039;&amp;#039;&amp;#039; Set the access permissions for the named pipe.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;`-Z context`:&amp;#039;&amp;#039;&amp;#039; Set the SELinux security context for the named pipe.&lt;br /&gt;
&lt;br /&gt;
==Real-World Use Cases==&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Transferring data between two programs:&amp;#039;&amp;#039;&amp;#039; For example, redirecting output from one program to the input of another.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Implementing a simple queue:&amp;#039;&amp;#039;&amp;#039; Data written to the named pipe will be processed sequentially by the reading process.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Communication between parent and child processes:&amp;#039;&amp;#039;&amp;#039; The child process can read commands from the parent process through a named pipe.&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;mkfifo&amp;#039;&amp;#039;&amp;#039; is a highly useful tool for building more complex and efficient systems on Ubuntu Server. By understanding how it works, you can leverage it for various purposes, from inter-process communication to implementing synchronization mechanisms.&lt;br /&gt;
&lt;br /&gt;
==Interesting Links==&lt;br /&gt;
&lt;br /&gt;
* [[Forensic: IT]]&lt;/div&gt;</summary>
		<author><name>Unknown user</name></author>
	</entry>
</feed>