<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Linux on Artur Meski</title>
    <link>https://meski.io/tags/linux/</link>
    <description>Recent content in Linux on Artur Meski</description>
    <generator>Hugo</generator>
    <language>en-gb</language>
    <lastBuildDate>Wed, 23 Jun 2021 00:00:00 +0000</lastBuildDate>
    <atom:link href="https://meski.io/tags/linux/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Basic concurrency with fork()</title>
      <link>https://meski.io/posts/concurrency-unix-fork/</link>
      <pubDate>Wed, 23 Jun 2021 00:00:00 +0000</pubDate>
      <guid>https://meski.io/posts/concurrency-unix-fork/</guid>
      <description>&lt;p&gt;When programming on Linux/Unix, the function &lt;a href=&#34;https://man.openbsd.org/fork&#34; target=&#34;_blank&#34;&gt;fork(2)&lt;/a&gt; allows us to create new processes.&#xA;This is a short and example-driven introduction to the basics of using that function.&lt;/p&gt;&#xA;&lt;h1 id=&#34;first-stab&#34;&gt;First stab&lt;/h1&gt;&#xA;&lt;p&gt;After a brief look at the manual page for &lt;a href=&#34;https://man.openbsd.org/fork&#34; target=&#34;_blank&#34;&gt;fork(2)&lt;/a&gt; we can tell that it returns a value of type &lt;em&gt;pid_t&lt;/em&gt; and does not take any arguments:&lt;/p&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;NAME&#xA;     fork – create a new process&#xA;&#xA;SYNOPSIS&#xA;     #include &amp;lt;unistd.h&amp;gt;&#xA;&#xA;     pid_t&#xA;     fork(void);&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Let us simply call &lt;em&gt;fork&lt;/em&gt; and see what happens and what values does it return.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Reading and monitoring files on Linux</title>
      <link>https://meski.io/posts/reading-and-monitoring-files/</link>
      <pubDate>Sat, 19 Jun 2021 00:00:00 +0000</pubDate>
      <guid>https://meski.io/posts/reading-and-monitoring-files/</guid>
      <description>&lt;p&gt;Let&amp;rsquo;s start with something super basic. To print the contents of a file you can use &lt;code&gt;cat&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;cat file&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This tool is simple but really powerful when combined (piped) with other commands.&#xA;However, &lt;code&gt;cat&lt;/code&gt; is not very practical if you just want to see the contents of a larger file.&#xA;In that case you can use &lt;code&gt;less&lt;/code&gt;, which also allows you to conveniently browse your file:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;press &lt;em&gt;space&lt;/em&gt; for &lt;em&gt;page down&lt;/em&gt; or &lt;code&gt;b&lt;/code&gt; for &lt;em&gt;page up&lt;/em&gt;,&lt;/li&gt;&#xA;&lt;li&gt;type &lt;code&gt;/pattern&lt;/code&gt; to search for &lt;code&gt;pattern&lt;/code&gt; in the file (&lt;code&gt;n&lt;/code&gt; jumps to the next occurence, while &lt;code&gt;N&lt;/code&gt; jumps to the previous one),&lt;/li&gt;&#xA;&lt;li&gt;press &lt;code&gt;q&lt;/code&gt; to quit.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;If you need to watch a certain file (typically a log file), you can simply use &lt;code&gt;tail -f&lt;/code&gt;:&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
