<?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: Naval Kishor Upadhyay</title>
    <description>The latest articles on DEV Community by Naval Kishor Upadhyay (@naval_upadhyay).</description>
    <link>https://dev.to/naval_upadhyay</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%2F3434984%2F2911642a-02b8-4e6a-bbb6-88cea652528d.png</url>
      <title>DEV Community: Naval Kishor Upadhyay</title>
      <link>https://dev.to/naval_upadhyay</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/naval_upadhyay"/>
    <language>en</language>
    <item>
      <title>Archiving &amp; Compression in Linux — From `.tar` to `.gz` and Beyond</title>
      <dc:creator>Naval Kishor Upadhyay</dc:creator>
      <pubDate>Tue, 16 Sep 2025 14:22:25 +0000</pubDate>
      <link>https://dev.to/naval_upadhyay/archiving-compression-in-linux-from-tar-to-gz-and-beyond-56dd</link>
      <guid>https://dev.to/naval_upadhyay/archiving-compression-in-linux-from-tar-to-gz-and-beyond-56dd</guid>
      <description>&lt;p&gt;When working with files in Linux, two words often come up: &lt;strong&gt;archiving&lt;/strong&gt; and &lt;strong&gt;compression&lt;/strong&gt;. Many people confuse them, but they’re not the same. Archiving is about &lt;strong&gt;grouping files&lt;/strong&gt;, while compression is about &lt;strong&gt;shrinking size&lt;/strong&gt;. Tools like &lt;code&gt;tar&lt;/code&gt;, &lt;code&gt;gzip&lt;/code&gt;, &lt;code&gt;bzip2&lt;/code&gt;, and &lt;code&gt;xz&lt;/code&gt; often get combined to give us familiar formats like &lt;code&gt;.tar.gz&lt;/code&gt;.  &lt;/p&gt;

&lt;p&gt;This article explains the differences, how Linux handles packaging, and why sometimes “smaller” isn’t always better.  &lt;/p&gt;




&lt;h2&gt;
  
  
  1. Archiving vs Compressing
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Archiving&lt;/strong&gt; = putting multiple files into one container.  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Think of it like putting many documents into one folder.
&lt;/li&gt;
&lt;li&gt;No size is saved, but organization improves.
&lt;/li&gt;
&lt;li&gt;Tool in Linux: &lt;code&gt;tar&lt;/code&gt; (short for &lt;strong&gt;tape archive&lt;/strong&gt;).
&lt;/li&gt;
&lt;li&gt;Output: &lt;code&gt;.tar&lt;/code&gt; file (all files combined, but still full size).
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Compressing&lt;/strong&gt; = making a file smaller using algorithms.  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Think of it like squeezing the air out of a bag of clothes.
&lt;/li&gt;
&lt;li&gt;Reduces disk space, faster transfers.
&lt;/li&gt;
&lt;li&gt;Tools in Linux: &lt;code&gt;gzip&lt;/code&gt;, &lt;code&gt;bzip2&lt;/code&gt;, &lt;code&gt;xz&lt;/code&gt;.
&lt;/li&gt;
&lt;li&gt;Output: &lt;code&gt;.gz&lt;/code&gt;, &lt;code&gt;.bz2&lt;/code&gt;, &lt;code&gt;.xz&lt;/code&gt;.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;📌 That’s why you often see combined extensions:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;.tar.gz&lt;/code&gt; → first archived, then compressed with gzip.
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;.tar.bz2&lt;/code&gt; → archived, then compressed with bzip2.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;👉 Without &lt;code&gt;tar&lt;/code&gt;, you’d need to compress files one by one. With &lt;code&gt;tar&lt;/code&gt;, you can compress whole directories at once.  &lt;/p&gt;




&lt;h2&gt;
  
  
  2. Lossless vs Lossy Compression
&lt;/h2&gt;

&lt;p&gt;Not all compression works the same way.  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Lossless compression&lt;/strong&gt;:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;No data is lost.
&lt;/li&gt;
&lt;li&gt;When decompressed, you get the original file exactly.
&lt;/li&gt;
&lt;li&gt;Used for text, logs, executables, source code.
&lt;/li&gt;
&lt;li&gt;Examples: &lt;code&gt;gzip&lt;/code&gt;, &lt;code&gt;bzip2&lt;/code&gt;, &lt;code&gt;xz&lt;/code&gt;.
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;strong&gt;Lossy compression&lt;/strong&gt;:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Some data is thrown away to make files much smaller.
&lt;/li&gt;
&lt;li&gt;The original cannot be perfectly reconstructed.
&lt;/li&gt;
&lt;li&gt;Used for multimedia where some quality loss is acceptable.
&lt;/li&gt;
&lt;li&gt;Examples: JPEG (images), MP3 (audio), MP4 (video).
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;📌 Linux archiving tools almost always use &lt;strong&gt;lossless compression&lt;/strong&gt;, because system files and source code must remain intact.  &lt;/p&gt;




&lt;h2&gt;
  
  
  3. Tarballs and Beyond
&lt;/h2&gt;

&lt;p&gt;A &lt;strong&gt;tarball&lt;/strong&gt; is simply a &lt;code&gt;.tar&lt;/code&gt; archive, often with compression added.  &lt;/p&gt;

&lt;p&gt;Examples:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;.tar.gz&lt;/code&gt; (also &lt;code&gt;.tgz&lt;/code&gt;) → tar archive + gzip
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;.tar.bz2&lt;/code&gt; → tar archive + bzip2
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;.tar.xz&lt;/code&gt; → tar archive + xz
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;What makes tarballs powerful?  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;They &lt;strong&gt;preserve metadata&lt;/strong&gt;:

&lt;ul&gt;
&lt;li&gt;File names, directory structure
&lt;/li&gt;
&lt;li&gt;Permissions and ownership
&lt;/li&gt;
&lt;li&gt;Timestamps
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;This makes them perfect for:

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Backups&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Source code distribution&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Software packaging&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;👉 That’s why most open-source projects ship their code as tarballs.  &lt;/p&gt;




&lt;h2&gt;
  
  
  4. The Trade-Offs of Compression
&lt;/h2&gt;

&lt;p&gt;Compression saves space — but it isn’t free. It uses &lt;strong&gt;CPU and time&lt;/strong&gt;. Different algorithms have different trade-offs:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;gzip&lt;/strong&gt;:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Fast, widely supported
&lt;/li&gt;
&lt;li&gt;Moderate compression ratio
&lt;/li&gt;
&lt;li&gt;Great for general use
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;strong&gt;bzip2&lt;/strong&gt;:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Slower than gzip
&lt;/li&gt;
&lt;li&gt;Better compression
&lt;/li&gt;
&lt;li&gt;Often used for source code archives
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;strong&gt;xz&lt;/strong&gt;:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Very high compression
&lt;/li&gt;
&lt;li&gt;Much slower
&lt;/li&gt;
&lt;li&gt;Good when space matters more than speed
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;📌 Choosing the right tool depends on the situation:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Sending files quickly → &lt;code&gt;gzip&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Archiving source code → &lt;code&gt;bzip2&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Packing large backups for long-term storage → &lt;code&gt;xz&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;👉 The smaller the file, the more CPU time and memory it usually costs to compress and decompress.  &lt;/p&gt;




&lt;h2&gt;
  
  
  6. Key Takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Archiving (&lt;code&gt;tar&lt;/code&gt;) = grouping files, no size reduction.
&lt;/li&gt;
&lt;li&gt;Compression (&lt;code&gt;gzip&lt;/code&gt;, &lt;code&gt;bzip2&lt;/code&gt;, &lt;code&gt;xz&lt;/code&gt;) = shrinking files.
&lt;/li&gt;
&lt;li&gt;Combined formats like &lt;code&gt;.tar.gz&lt;/code&gt; do both.
&lt;/li&gt;
&lt;li&gt;Lossless compression keeps data exact; lossy permanently drops details.
&lt;/li&gt;
&lt;li&gt;Tarballs preserve directory structure, metadata, and permissions — ideal for Linux backups and source code.
&lt;/li&gt;
&lt;li&gt;Choosing gzip, bzip2, or xz is a balance of &lt;strong&gt;speed vs size&lt;/strong&gt;.
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>linux</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Linux Filesystem Explained — From `/` to `/home` (and Everything Between)</title>
      <dc:creator>Naval Kishor Upadhyay</dc:creator>
      <pubDate>Mon, 15 Sep 2025 08:25:11 +0000</pubDate>
      <link>https://dev.to/naval_upadhyay/linux-filesystem-explained-from-to-home-and-everything-between-23d8</link>
      <guid>https://dev.to/naval_upadhyay/linux-filesystem-explained-from-to-home-and-everything-between-23d8</guid>
      <description>&lt;p&gt;When you first explore a Linux system, the directories may seem cryptic:&lt;br&gt;&lt;br&gt;
&lt;code&gt;/bin&lt;/code&gt;, &lt;code&gt;/etc&lt;/code&gt;, &lt;code&gt;/usr&lt;/code&gt;, &lt;code&gt;/var&lt;/code&gt; … what do they mean, and why are they there?  &lt;/p&gt;

&lt;p&gt;The truth is: the Linux filesystem is &lt;strong&gt;not random&lt;/strong&gt;. It’s carefully structured, following the &lt;strong&gt;Filesystem Hierarchy Standard (FHS)&lt;/strong&gt;. Once you see the logic, it becomes predictable and powerful.  &lt;/p&gt;

&lt;p&gt;This guide takes you step by step through the &lt;strong&gt;Linux directory tree&lt;/strong&gt;, explaining what each folder contains, why it exists, and how to explore it.&lt;/p&gt;


&lt;h2&gt;
  
  
  1. The Root &lt;code&gt;/&lt;/code&gt; — the Starting Point
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;At the very top is the &lt;strong&gt;root directory (&lt;code&gt;/&lt;/code&gt;)&lt;/strong&gt;.
&lt;/li&gt;
&lt;li&gt;Every file and folder in Linux grows from this one root, like branches of a tree.
&lt;/li&gt;
&lt;/ul&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;/home/alex/report.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;/&lt;/code&gt; → root (the trunk)
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;home&lt;/code&gt; → branch
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;alex&lt;/code&gt; → smaller branch
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;report.txt&lt;/code&gt; → the leaf (file)
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Unlike Windows, Linux does not use &lt;code&gt;C:\&lt;/code&gt; or &lt;code&gt;D:\&lt;/code&gt;. Disks and USB drives are mounted &lt;strong&gt;into&lt;/strong&gt; this tree.  &lt;/p&gt;

&lt;p&gt;Try this:&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;ls&lt;/span&gt; /
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  2. System Essentials
&lt;/h2&gt;

&lt;p&gt;These directories allow Linux to start and run, even before you log in.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;/bin&lt;/code&gt; — Basic Commands
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Stores essential tools always available.
&lt;/li&gt;
&lt;li&gt;Examples: &lt;code&gt;ls&lt;/code&gt;, &lt;code&gt;cp&lt;/code&gt;, &lt;code&gt;mv&lt;/code&gt;, &lt;code&gt;cat&lt;/code&gt;.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;ls&lt;/span&gt; /bin | &lt;span class="nb"&gt;head&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;code&gt;/sbin&lt;/code&gt; — System Commands
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Utilities for system administration.
&lt;/li&gt;
&lt;li&gt;Examples: &lt;code&gt;ip&lt;/code&gt;, &lt;code&gt;mount&lt;/code&gt;, &lt;code&gt;shutdown&lt;/code&gt;.
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;/lib&lt;/code&gt; — Shared Libraries
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Libraries needed by &lt;code&gt;/bin&lt;/code&gt; and &lt;code&gt;/sbin&lt;/code&gt; programs.
&lt;/li&gt;
&lt;li&gt;Without these, commands won’t work.
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;/boot&lt;/code&gt; — Startup Files
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Holds files needed to boot Linux:

&lt;ul&gt;
&lt;li&gt;Kernel (&lt;code&gt;vmlinuz&lt;/code&gt;)
&lt;/li&gt;
&lt;li&gt;Bootloader (GRUB)
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;/etc&lt;/code&gt; — System Configuration
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Contains configuration files.
&lt;/li&gt;
&lt;li&gt;Examples:

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;/etc/passwd&lt;/code&gt; → user accounts
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;/etc/hosts&lt;/code&gt; → hostname mappings
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cat&lt;/span&gt; /etc/hostname
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  3. Programs and Applications
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;/usr&lt;/code&gt; — Program Files
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Houses the bulk of installed software.
&lt;/li&gt;
&lt;li&gt;Key subdirectories:

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;/usr/bin&lt;/code&gt; → executables
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;/usr/share&lt;/code&gt; → docs, icons, locales
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;/usr/local&lt;/code&gt; — Locally Installed Software
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;For software compiled or installed by the administrator.
&lt;/li&gt;
&lt;li&gt;Keeps it separate from system-installed programs.
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;/opt&lt;/code&gt; — Optional Applications
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Self-contained third-party software.
&lt;/li&gt;
&lt;li&gt;Example: &lt;code&gt;/opt/google/chrome&lt;/code&gt;.
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  4. User Data
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;/home&lt;/code&gt; — User Directories
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Each user has their own space.
&lt;/li&gt;
&lt;li&gt;Example: &lt;code&gt;/home/alex/&lt;/code&gt; → personal files and configs.
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;/root&lt;/code&gt; — Administrator’s Home
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The root user’s home directory.
&lt;/li&gt;
&lt;li&gt;Kept separate from &lt;code&gt;/home&lt;/code&gt; so it’s always accessible.
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  5. Variable Data
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;/var&lt;/code&gt; — Logs and State
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Contains files that change during operation.
&lt;/li&gt;
&lt;li&gt;Examples:

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;/var/log/&lt;/code&gt; → log files
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;/var/lib/&lt;/code&gt; → databases
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;/var/cache/&lt;/code&gt; → cached files
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;ls&lt;/span&gt; /var/log
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;code&gt;/tmp&lt;/code&gt; — Temporary Files
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Used by programs for short-lived data.
&lt;/li&gt;
&lt;li&gt;Cleared on reboot.
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;/var/tmp&lt;/code&gt; — Longer Temporary Storage
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Similar to &lt;code&gt;/tmp&lt;/code&gt;, but files may survive reboots.
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  6. Devices and System Information
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;/dev&lt;/code&gt; — Devices as Files
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Hardware appears as files.
&lt;/li&gt;
&lt;li&gt;Examples:

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;/dev/sda&lt;/code&gt; → first hard disk
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;/dev/tty&lt;/code&gt; → terminal
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;/dev/null&lt;/code&gt; → discards data
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;ls&lt;/span&gt; /dev | &lt;span class="nb"&gt;head&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;code&gt;/proc&lt;/code&gt; — Process and Kernel Info
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Virtual files representing system state.
&lt;/li&gt;
&lt;li&gt;Examples:

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;/proc/cpuinfo&lt;/code&gt; → CPU info
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;/proc/meminfo&lt;/code&gt; → memory usage
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cat&lt;/span&gt; /proc/cpuinfo | &lt;span class="nb"&gt;head&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;code&gt;/sys&lt;/code&gt; — Device and Kernel Settings
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Exposes kernel and device details.
&lt;/li&gt;
&lt;li&gt;Example: &lt;code&gt;/sys/class/net/&lt;/code&gt; shows network interfaces.
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  7. Mount Points
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;/mnt&lt;/code&gt; — Manual Mounts
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Used for temporary, admin-controlled mounts.
&lt;/li&gt;
&lt;/ul&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;mount /dev/sdb1 /mnt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;code&gt;/media&lt;/code&gt; — Removable Media
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Where USBs and external drives appear automatically.
&lt;/li&gt;
&lt;li&gt;Example: &lt;code&gt;/media/alex/MyUSB/&lt;/code&gt;.
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  8. Other Directories
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;/srv&lt;/code&gt; → Data for services (web, FTP, etc.)
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;/run&lt;/code&gt; → Runtime info about processes and sockets (cleared at reboot)
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;/lost+found&lt;/code&gt; → Recovered files after filesystem checks
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;/snap&lt;/code&gt;, &lt;code&gt;/flatpak&lt;/code&gt; → Application packaging (distro-specific)
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  9. Key Takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;/&lt;/code&gt; is the single starting point of the filesystem.
&lt;/li&gt;
&lt;li&gt;System essentials live in &lt;code&gt;/bin&lt;/code&gt;, &lt;code&gt;/sbin&lt;/code&gt;, &lt;code&gt;/lib&lt;/code&gt;, &lt;code&gt;/boot&lt;/code&gt;.
&lt;/li&gt;
&lt;li&gt;Configurations are in &lt;code&gt;/etc&lt;/code&gt;.
&lt;/li&gt;
&lt;li&gt;Applications go into &lt;code&gt;/usr&lt;/code&gt;, &lt;code&gt;/usr/local&lt;/code&gt;, &lt;code&gt;/opt&lt;/code&gt;.
&lt;/li&gt;
&lt;li&gt;User files are stored in &lt;code&gt;/home/&amp;lt;username&amp;gt;&lt;/code&gt;.
&lt;/li&gt;
&lt;li&gt;Logs and caches go into &lt;code&gt;/var&lt;/code&gt;, while temp data is in &lt;code&gt;/tmp&lt;/code&gt;.
&lt;/li&gt;
&lt;li&gt;Hardware and system info appear in &lt;code&gt;/dev&lt;/code&gt;, &lt;code&gt;/proc&lt;/code&gt;, &lt;code&gt;/sys&lt;/code&gt;.
&lt;/li&gt;
&lt;li&gt;Mount points for external storage are &lt;code&gt;/media&lt;/code&gt; and &lt;code&gt;/mnt&lt;/code&gt;.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Once you know this structure, navigating Linux feels much more natural, and you’ll always know where to look for programs, configurations, logs, or personal data.  &lt;/p&gt;

</description>
      <category>linux</category>
      <category>beginners</category>
    </item>
    <item>
      <title>System Calls and Interactions in Linux</title>
      <dc:creator>Naval Kishor Upadhyay</dc:creator>
      <pubDate>Mon, 15 Sep 2025 08:03:46 +0000</pubDate>
      <link>https://dev.to/naval_upadhyay/system-calls-and-interactions-in-linux-207j</link>
      <guid>https://dev.to/naval_upadhyay/system-calls-and-interactions-in-linux-207j</guid>
      <description>&lt;p&gt;Linux systems rely on a clean separation between &lt;strong&gt;applications (user space)&lt;/strong&gt; and the &lt;strong&gt;kernel (kernel space)&lt;/strong&gt;. To bridge the two, the operating system uses &lt;strong&gt;system calls&lt;/strong&gt; — controlled gateways that allow programs to request kernel services safely.  &lt;/p&gt;

&lt;p&gt;Alongside system calls, Linux also has mechanisms like &lt;strong&gt;ring buffers for logging&lt;/strong&gt; and the distinction between &lt;strong&gt;internal and external commands&lt;/strong&gt; that affect how user actions are handled.  &lt;/p&gt;




&lt;h2&gt;
  
  
  1. System Calls: How Programs Ask the Kernel for Help
&lt;/h2&gt;

&lt;h3&gt;
  
  
  What They Are
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;A &lt;strong&gt;system call&lt;/strong&gt; is a special function that allows user programs to request services from the kernel.
&lt;/li&gt;
&lt;li&gt;Since user space cannot directly access hardware, system calls are the only safe pathway into kernel space.
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Examples of Services
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;File operations:&lt;/strong&gt; open, read, write, close.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Process control:&lt;/strong&gt; fork, exec, exit, wait.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Memory management:&lt;/strong&gt; mmap, brk (allocate/free memory).
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Networking:&lt;/strong&gt; socket, bind, send, recv.
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  How It Works (Step-by-Step)
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;A user program calls a standard library function (e.g., &lt;code&gt;printf&lt;/code&gt;).
&lt;/li&gt;
&lt;li&gt;The library translates this into the appropriate &lt;strong&gt;system call&lt;/strong&gt; (&lt;code&gt;write&lt;/code&gt; in this case).
&lt;/li&gt;
&lt;li&gt;A &lt;strong&gt;software interrupt / trap&lt;/strong&gt; transfers control to the kernel.
&lt;/li&gt;
&lt;li&gt;The kernel executes the request in kernel space.
&lt;/li&gt;
&lt;li&gt;The result is passed back to user space.
&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Diagram
&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%2Fl6mjncjc73huok9zmp3g.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%2Fl6mjncjc73huok9zmp3g.png" alt=" " width="570" height="1024"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  2. Ring Buffers and &lt;code&gt;dmesg&lt;/code&gt;: How Linux Logs What Happens Inside
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Ring Buffer Concept
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;A &lt;strong&gt;ring buffer&lt;/strong&gt; is a fixed-size, circular data structure.
&lt;/li&gt;
&lt;li&gt;When it fills up, new messages overwrite the oldest ones.
&lt;/li&gt;
&lt;li&gt;Used by the kernel to log events efficiently without growing indefinitely.
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Kernel Logging
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The Linux kernel uses a ring buffer to store messages about:

&lt;ul&gt;
&lt;li&gt;Hardware detection during boot.
&lt;/li&gt;
&lt;li&gt;Driver initialization.
&lt;/li&gt;
&lt;li&gt;Errors and warnings.
&lt;/li&gt;
&lt;li&gt;Debug information.
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h3&gt;
  
  
  Accessing Logs
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;dmesg&lt;/code&gt; command displays the kernel ring buffer.
&lt;/li&gt;
&lt;li&gt;Examples:

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;dmesg | grep usb&lt;/code&gt; → check USB device detection.
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;dmesg -T&lt;/code&gt; → show timestamps in human-readable format.
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h3&gt;
  
  
  Diagram
&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%2Fqiza3teyu0rfkt6ttg0e.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%2Fqiza3teyu0rfkt6ttg0e.png" alt=" " width="800" height="109"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  3. Internal vs External Commands: What Really Runs When You Type
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Internal Commands
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Built into the shell itself (e.g., &lt;code&gt;cd&lt;/code&gt;, &lt;code&gt;echo&lt;/code&gt;, &lt;code&gt;pwd&lt;/code&gt;).
&lt;/li&gt;
&lt;li&gt;Execute directly in the shell process.
&lt;/li&gt;
&lt;li&gt;No system call to start a new process is required.
&lt;/li&gt;
&lt;li&gt;Faster, but limited to shell-provided functionality.
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  External Commands
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Separate executable programs stored on disk (e.g., &lt;code&gt;/bin/ls&lt;/code&gt;, &lt;code&gt;/usr/bin/grep&lt;/code&gt;).
&lt;/li&gt;
&lt;li&gt;The shell uses a &lt;strong&gt;system call&lt;/strong&gt; (&lt;code&gt;fork&lt;/code&gt; + &lt;code&gt;exec&lt;/code&gt;) to create a new process that runs the program.
&lt;/li&gt;
&lt;li&gt;More flexible, but slightly slower because of process creation.
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Why It Matters
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Understanding the difference helps in scripting and debugging.
&lt;/li&gt;
&lt;li&gt;For example:

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;type cd&lt;/code&gt; → shows it’s a shell builtin.
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;type ls&lt;/code&gt; → shows the path to the external binary.
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&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%2Ft4am132c0actea50znwi.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%2Ft4am132c0actea50znwi.png" alt=" " width="800" height="907"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Final Takeaway
&lt;/h2&gt;

&lt;p&gt;Linux interactions revolve around three core ideas:  &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;System Calls&lt;/strong&gt; provide the controlled gateway between user applications and the kernel.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ring Buffers&lt;/strong&gt; give the kernel an efficient way to log events, accessible with &lt;code&gt;dmesg&lt;/code&gt;.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Internal vs External Commands&lt;/strong&gt; determine whether a command runs instantly inside the shell or launches a separate process.
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Together, these mechanisms ensure Linux stays &lt;strong&gt;efficient, secure, and transparent&lt;/strong&gt;, giving both developers and users insight into how the system really works.  &lt;/p&gt;

</description>
      <category>linux</category>
      <category>devops</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Linux System Architecture</title>
      <dc:creator>Naval Kishor Upadhyay</dc:creator>
      <pubDate>Mon, 15 Sep 2025 07:57:35 +0000</pubDate>
      <link>https://dev.to/naval_upadhyay/linux-system-architecture-4g89</link>
      <guid>https://dev.to/naval_upadhyay/linux-system-architecture-4g89</guid>
      <description>&lt;p&gt;Linux is often praised for being powerful, efficient, and flexible. Much of this comes from its underlying &lt;strong&gt;system architecture&lt;/strong&gt; — how the kernel is designed, how it separates work between kernel space and user space, and how it manages core resources like processes, memory, and devices.  &lt;/p&gt;




&lt;h2&gt;
  
  
  1. Monolithic vs Modular Kernels
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Monolithic Kernel
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Definition:&lt;/strong&gt; In a monolithic kernel, nearly all operating system services run directly in &lt;strong&gt;kernel space&lt;/strong&gt;.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Advantages:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Very fast because all components can directly call each other.
&lt;/li&gt;
&lt;li&gt;Efficient internal communication and execution.
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;strong&gt;Disadvantages:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Large codebase, harder to maintain.
&lt;/li&gt;
&lt;li&gt;A bug in a driver can crash the whole system.
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h3&gt;
  
  
  Modular Kernel
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Definition:&lt;/strong&gt; A modular kernel allows functionality to be added or removed at runtime using &lt;strong&gt;loadable kernel modules (LKMs)&lt;/strong&gt;.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Advantages:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Flexible: load only the needed drivers.
&lt;/li&gt;
&lt;li&gt;Easier updates: replace a module without rebooting.
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;strong&gt;Disadvantages:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Slightly slower due to extra indirection.
&lt;/li&gt;
&lt;li&gt;Dependency management adds complexity.
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;




&lt;h2&gt;
  
  
  2. Kernel Space vs User Space
&lt;/h2&gt;

&lt;p&gt;Linux divides memory into two regions: &lt;strong&gt;kernel space&lt;/strong&gt; and &lt;strong&gt;user space&lt;/strong&gt;.  &lt;/p&gt;

&lt;h3&gt;
  
  
  Kernel Space
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Privileged memory area where the kernel runs.
&lt;/li&gt;
&lt;li&gt;Full access to CPU, RAM, and devices.
&lt;/li&gt;
&lt;li&gt;Manages processes, memory, and devices.
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  User Space
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Where applications and user processes run.
&lt;/li&gt;
&lt;li&gt;Cannot directly access hardware.
&lt;/li&gt;
&lt;li&gt;Relies on &lt;strong&gt;system calls&lt;/strong&gt; to request kernel services.
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Interaction
&lt;/h3&gt;

&lt;p&gt;Applications in user space communicate with the kernel through &lt;strong&gt;system calls&lt;/strong&gt;.  &lt;/p&gt;




&lt;h2&gt;
  
  
  3. The Kernel’s Three Big Jobs
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Process Management
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Creates, schedules, and terminates processes.
&lt;/li&gt;
&lt;li&gt;Ensures fair CPU time allocation.
&lt;/li&gt;
&lt;li&gt;Coordinates communication between processes.
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Memory Management
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Allocates and frees memory.
&lt;/li&gt;
&lt;li&gt;Provides virtual memory using disk swap.
&lt;/li&gt;
&lt;li&gt;Ensures isolation between processes.
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Device Management
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Provides a consistent interface to hardware via device drivers.
&lt;/li&gt;
&lt;li&gt;Manages input/output operations.
&lt;/li&gt;
&lt;li&gt;Abstracts hardware details for applications.
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Final Takeaway
&lt;/h2&gt;

&lt;p&gt;Linux system architecture is built on three key pillars:  &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Kernel design&lt;/strong&gt;: Monolithic (fast, but less flexible) vs Modular (flexible, but slightly complex).
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Memory separation&lt;/strong&gt;: Kernel space and user space ensure stability and protection.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Core responsibilities&lt;/strong&gt;: Process, memory, and device management keep the OS stable and efficient.
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Understanding these concepts is essential for developers, sysadmins, and anyone curious about how Linux works under the hood.  &lt;/p&gt;

</description>
      <category>linux</category>
      <category>beginners</category>
      <category>devops</category>
    </item>
    <item>
      <title>Linux Boot Process: From Power-On to Login</title>
      <dc:creator>Naval Kishor Upadhyay</dc:creator>
      <pubDate>Mon, 15 Sep 2025 07:51:05 +0000</pubDate>
      <link>https://dev.to/naval_upadhyay/linux-boot-process-from-power-on-to-login-j6f</link>
      <guid>https://dev.to/naval_upadhyay/linux-boot-process-from-power-on-to-login-j6f</guid>
      <description>&lt;p&gt;Booting a Linux system is a chain of handoffs: firmware initializes hardware, a bootloader loads the kernel, the kernel prepares the system, and &lt;code&gt;systemd&lt;/code&gt; brings user space to life.&lt;/p&gt;




&lt;h2&gt;
  
  
  High-Level Overview
&lt;/h2&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%2Fswkktmffzwy6p65tru0h.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%2Fswkktmffzwy6p65tru0h.png" alt=" " width="516" height="1084"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  1) Power-On, POST, and Firmware (BIOS/UEFI)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;POST (Power-On Self-Test)&lt;/strong&gt; verifies CPU, RAM, basic chipset, storage controllers, and peripherals.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Hardware initialization&lt;/strong&gt; configures controllers (SATA/NVMe/USB, GPU, timers) so code can be read from disks/USB/Net.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Boot selection&lt;/strong&gt; uses a firmware-defined order to choose a bootable device (SSD/HDD/USB/Network).&lt;/li&gt;
&lt;/ul&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%2Fw8vhy7pcsiwxn9hmsg6n.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%2Fw8vhy7pcsiwxn9hmsg6n.png" alt=" " width="800" height="435"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  2) Primary vs Secondary Boot Loader
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Primary boot loader (BIOS/MBR)&lt;/strong&gt;: ~446 bytes of code at disk sector 0; too small for menus/filesystems—just finds and loads next stage.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;UEFI&lt;/strong&gt;: loads an EFI executable (e.g., &lt;code&gt;\EFI\GRUB\grubx64.efi&lt;/code&gt;, &lt;code&gt;\EFI\systemd\systemd-bootx64.efi&lt;/code&gt;) from the &lt;strong&gt;EFI System Partition (ESP)&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Secondary boot loader&lt;/strong&gt; (e.g., &lt;strong&gt;GRUB&lt;/strong&gt;, &lt;strong&gt;systemd-boot&lt;/strong&gt;): shows a menu, accepts kernel parameters, loads &lt;strong&gt;kernel&lt;/strong&gt; and &lt;strong&gt;initramfs&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&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%2Fo7sesxsfmty7sdhl9ujf.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%2Fo7sesxsfmty7sdhl9ujf.png" alt=" " width="800" height="605"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Common kernel parameters&lt;/strong&gt; (set by the bootloader):&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;root=&lt;/code&gt; (e.g., &lt;code&gt;root=/dev/nvme0n1p2&lt;/code&gt; or &lt;code&gt;root=UUID=...&lt;/code&gt;) – tells the kernel where the real root filesystem is.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;ro&lt;/code&gt;/&lt;code&gt;rw&lt;/code&gt; – mount root initially read-only or read-write.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;quiet&lt;/code&gt;/&lt;code&gt;verbose&lt;/code&gt; – control console verbosity.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;single&lt;/code&gt; or &lt;code&gt;systemd.unit=rescue.target&lt;/code&gt; – maintenance boot modes.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;init=&lt;/code&gt; – override PID 1 (rare, for rescue/debug).&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  3) Kernel Initialization (Early Userspace with initramfs)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Kernel decompression &amp;amp; start&lt;/strong&gt;: kernel unpacks in RAM and begins execution.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Hardware bring-up&lt;/strong&gt;: CPU &amp;amp; SMP, memory manager &amp;amp; page tables, device buses (PCI/USB), interrupts &amp;amp; timers.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Driver loading&lt;/strong&gt;: built-in drivers + modules from &lt;strong&gt;initramfs&lt;/strong&gt; to access storage, crypto, filesystems, etc.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Root filesystem discovery&lt;/strong&gt;: initramfs scripts discover and mount the &lt;strong&gt;real root FS&lt;/strong&gt;, then &lt;code&gt;pivot_root&lt;/code&gt;/&lt;code&gt;switch_root&lt;/code&gt; to it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;PID 1 start&lt;/strong&gt;: kernel executes the first userspace process (normally &lt;strong&gt;&lt;code&gt;/sbin/init&lt;/code&gt; → &lt;code&gt;systemd&lt;/code&gt;&lt;/strong&gt;).&lt;/li&gt;
&lt;/ul&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%2F7v81jjz3lxtbch6885em.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%2F7v81jjz3lxtbch6885em.png" alt=" " width="800" height="91"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  4) systemd Takes Over (PID 1)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Unit files&lt;/strong&gt; describe services, sockets, timers, mounts, targets (goal states).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Parallel startup&lt;/strong&gt; honors dependencies (&lt;code&gt;After=&lt;/code&gt;, &lt;code&gt;Wants=&lt;/code&gt;, &lt;code&gt;Requires=&lt;/code&gt;) to speed boot.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Targets&lt;/strong&gt; replace SysV runlevels:

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;rescue.target&lt;/code&gt; (single-user), &lt;code&gt;multi-user.target&lt;/code&gt; (server/text), &lt;code&gt;graphical.target&lt;/code&gt; (desktop).&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;strong&gt;Key tools&lt;/strong&gt;: &lt;code&gt;systemctl&lt;/code&gt; (control units), &lt;code&gt;journalctl&lt;/code&gt; (logs), &lt;code&gt;systemd-analyze&lt;/code&gt; (boot timing).&lt;/li&gt;

&lt;/ul&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%2Fzsoqokban9qw7mxaecfc.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%2Fzsoqokban9qw7mxaecfc.png" alt=" " width="800" height="350"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example service dependencies&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;network-online.target&lt;/code&gt; before services needing network (e.g., &lt;code&gt;docker.service&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;local-fs.target&lt;/code&gt; ensures local filesystems are mounted before dependent services.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  5) Login Stage
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Server consoles&lt;/strong&gt;: systemd spawns &lt;code&gt;agetty@ttyX.service&lt;/code&gt; for virtual TTYs (Ctrl+Alt+F1..F6).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Desktops&lt;/strong&gt;: a Display Manager (GDM, SDDM, LightDM) provides GUI login and launches the session (GNOME/KDE/etc.).&lt;/li&gt;
&lt;li&gt;After authentication, shell or desktop session starts and userland completes initialization (user services, autostart apps).&lt;/li&gt;
&lt;/ul&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%2F5pu8r9ep7u6gfh9dm0sx.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%2F5pu8r9ep7u6gfh9dm0sx.png" alt=" " width="800" height="344"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  6) Common Failure Points &amp;amp; Recovery Hints
&lt;/h2&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%2Fbs8wrh5a0ck1uxp0btzx.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%2Fbs8wrh5a0ck1uxp0btzx.png" alt=" " width="800" height="282"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Firmware/Boot order&lt;/strong&gt;: ensure the correct disk/ESP entry is first.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;GRUB issues&lt;/strong&gt;: from live media, &lt;code&gt;chroot&lt;/code&gt; and reinstall &lt;code&gt;grub&lt;/code&gt;, regenerate configs (&lt;code&gt;grub-mkconfig&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Kernel panic (root FS)&lt;/strong&gt;: verify &lt;code&gt;root=UUID=...&lt;/code&gt;, rebuild initramfs (e.g., &lt;code&gt;dracut&lt;/code&gt;, &lt;code&gt;update-initramfs&lt;/code&gt;), confirm modules for storage controller.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Emergency/Rescue&lt;/strong&gt;: boot with &lt;code&gt;systemd.unit=rescue.target&lt;/code&gt;, inspect logs &lt;code&gt;journalctl -b -p err&lt;/code&gt;, disable problematic services with &lt;code&gt;systemctl disable --now ...&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Quick Reference: Useful Commands
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Firmware/ESP&lt;/strong&gt;: &lt;code&gt;efibootmgr -v&lt;/code&gt; (UEFI entries), &lt;code&gt;lsblk -f&lt;/code&gt; (filesystems &amp;amp; UUIDs)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Bootloader&lt;/strong&gt;: &lt;code&gt;grub-install&lt;/code&gt;, &lt;code&gt;grub-mkconfig -o /boot/grub/grub.cfg&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Kernel/initramfs&lt;/strong&gt;: &lt;code&gt;uname -a&lt;/code&gt;, &lt;code&gt;lsinitramfs&lt;/code&gt; / &lt;code&gt;lsinitrd&lt;/code&gt;, &lt;code&gt;update-initramfs -u&lt;/code&gt; / &lt;code&gt;dracut -f&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;systemd&lt;/strong&gt;: &lt;code&gt;systemd-analyze blame/critical-chain&lt;/code&gt;, &lt;code&gt;systemctl list-dependencies&lt;/code&gt;, &lt;code&gt;journalctl -b&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Final Takeaway
&lt;/h3&gt;

&lt;p&gt;From &lt;strong&gt;POST&lt;/strong&gt; to &lt;strong&gt;login&lt;/strong&gt;, Linux traverses predictable stages. Knowing where you are—firmware, bootloader, kernel, or &lt;code&gt;systemd&lt;/code&gt;—turns a mysterious “it won’t boot” into a solvable problem with concrete tools and checkpoints.&lt;/p&gt;

</description>
      <category>linux</category>
      <category>devops</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Udev and Device Events: What Happens When You Plug In a USB</title>
      <dc:creator>Naval Kishor Upadhyay</dc:creator>
      <pubDate>Mon, 15 Sep 2025 07:15:48 +0000</pubDate>
      <link>https://dev.to/naval_upadhyay/udev-and-device-events-what-happens-when-you-plug-in-a-usb-hkm</link>
      <guid>https://dev.to/naval_upadhyay/udev-and-device-events-what-happens-when-you-plug-in-a-usb-hkm</guid>
      <description>&lt;p&gt;When you connect a USB stick or external drive to a Linux system, the response feels almost magical: the system recognizes the device, mounts it, and sometimes even opens a file manager window.  &lt;/p&gt;

&lt;p&gt;Behind the scenes, however, there is a well-orchestrated chain of &lt;strong&gt;kernel events, daemons, and device nodes&lt;/strong&gt; working together. The central actor here is &lt;strong&gt;udev&lt;/strong&gt; — the Linux device manager.&lt;/p&gt;




&lt;h2&gt;
  
  
  1) Kernel Detection
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Event trigger&lt;/strong&gt;: The moment you insert the USB stick, the &lt;strong&gt;USB controller hardware&lt;/strong&gt; signals the kernel that a new device has been attached.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Driver binding&lt;/strong&gt;: The kernel checks its list of drivers to see if it has a suitable one for the device. If not, it may try to load a module dynamically.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Kernel role&lt;/strong&gt;: This entire step happens in &lt;strong&gt;kernel space&lt;/strong&gt;, where hardware is directly managed.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  2) Uevent Generation
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Once the kernel has recognized the device, it generates a &lt;strong&gt;uevent&lt;/strong&gt; (short for &lt;em&gt;user event&lt;/em&gt;).
&lt;/li&gt;
&lt;li&gt;The uevent contains important information, including:

&lt;ul&gt;
&lt;li&gt;Vendor and product IDs.
&lt;/li&gt;
&lt;li&gt;The type of device (e.g., storage, input).
&lt;/li&gt;
&lt;li&gt;The device’s connection path.
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;This event is the kernel’s way of telling &lt;strong&gt;user space&lt;/strong&gt;: &lt;em&gt;“A new device is here.”&lt;/em&gt;
&lt;/li&gt;

&lt;/ul&gt;




&lt;h2&gt;
  
  
  3) Udev Daemon (udevd)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;In &lt;strong&gt;user space&lt;/strong&gt;, the &lt;strong&gt;udevd daemon&lt;/strong&gt; constantly listens for these uevents.
&lt;/li&gt;
&lt;li&gt;Its responsibilities include:

&lt;ul&gt;
&lt;li&gt;Parsing the uevent details.
&lt;/li&gt;
&lt;li&gt;Applying any preconfigured udev rules.
&lt;/li&gt;
&lt;li&gt;Creating or removing the appropriate device nodes under &lt;code&gt;/dev&lt;/code&gt;.
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Example: When a USB drive is plugged in, udev creates entries such as &lt;code&gt;/dev/sdb&lt;/code&gt; and &lt;code&gt;/dev/sdb1&lt;/code&gt;.&lt;/li&gt;

&lt;/ul&gt;




&lt;h2&gt;
  
  
  4) Device Node Creation in &lt;code&gt;/dev&lt;/code&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Device nodes&lt;/strong&gt; are special files that act as communication channels to the hardware.
&lt;/li&gt;
&lt;li&gt;For a USB stick, these nodes typically appear as:

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;/dev/sdb&lt;/code&gt; → the whole device.
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;/dev/sdb1&lt;/code&gt; → the first partition on that device.
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Applications can now interact with the USB device just like they would with a normal file.&lt;/li&gt;

&lt;/ul&gt;




&lt;h2&gt;
  
  
  5) Higher-Level User Space Actions
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;After device nodes are created, &lt;strong&gt;higher-level processes&lt;/strong&gt; may take over.
&lt;/li&gt;
&lt;li&gt;On desktop systems:

&lt;ul&gt;
&lt;li&gt;Automount services (e.g., &lt;code&gt;udisks2&lt;/code&gt;) can mount the device automatically.
&lt;/li&gt;
&lt;li&gt;A file manager may open to show the new USB contents.
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;On servers without a GUI:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Manual mounting is common:
&lt;/li&gt;
&lt;/ul&gt;

&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;mount /dev/sdb1 /mnt/usb
&lt;/code&gt;&lt;/pre&gt;




&lt;/li&gt;

&lt;/ul&gt;




&lt;h2&gt;
  
  
  6) Monitoring Device Events
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;You can observe these steps in real time using:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  udevadm monitor
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;This shows:

&lt;ul&gt;
&lt;li&gt;Kernel uevents as they are generated.
&lt;/li&gt;
&lt;li&gt;Udev’s actions in response (such as creating device nodes).
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;This is a powerful way to troubleshoot if a device does not appear as expected.&lt;/li&gt;

&lt;/ul&gt;




&lt;h2&gt;
  
  
  7) Why This Matters
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Consistency&lt;/strong&gt;: Every device follows the same flow — kernel detects, uevent is sent, udev processes it, and &lt;code&gt;/dev&lt;/code&gt; entries are created.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Flexibility&lt;/strong&gt;: System administrators can write &lt;strong&gt;udev rules&lt;/strong&gt; to automate tasks, such as running a backup script when a specific USB drive is inserted.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Automation&lt;/strong&gt;: Users don’t have to configure devices manually; the system handles the process in real time.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Final Takeaway
&lt;/h2&gt;

&lt;p&gt;When you plug in a USB device, Linux follows a structured sequence:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The kernel detects the hardware.
&lt;/li&gt;
&lt;li&gt;A uevent is generated with device details.
&lt;/li&gt;
&lt;li&gt;The udev daemon listens and creates device nodes.
&lt;/li&gt;
&lt;li&gt;Higher-level processes mount the device or launch user-friendly actions.
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This flow demonstrates the elegance of Linux: the &lt;strong&gt;kernel manages detection&lt;/strong&gt;, while &lt;strong&gt;udev manages user-space handling&lt;/strong&gt;, giving us a consistent and automated hardware experience.&lt;/p&gt;

</description>
      <category>linux</category>
      <category>devops</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Special Files in Linux: The Hidden Power Behind “Everything is a File”</title>
      <dc:creator>Naval Kishor Upadhyay</dc:creator>
      <pubDate>Sun, 14 Sep 2025 18:11:58 +0000</pubDate>
      <link>https://dev.to/naval_upadhyay/special-files-in-linux-the-hidden-power-behind-everything-is-a-file-34j7</link>
      <guid>https://dev.to/naval_upadhyay/special-files-in-linux-the-hidden-power-behind-everything-is-a-file-34j7</guid>
      <description>&lt;h1&gt;
  
  
  Special Files in Linux: The Hidden Power Behind “Everything is a File”
&lt;/h1&gt;

&lt;p&gt;Linux follows the philosophy that &lt;strong&gt;“everything is a file.”&lt;/strong&gt; This means that hardware devices, inter-process communication, and even shortcuts to files are all represented using a consistent file interface. The practical enablers of this philosophy are &lt;strong&gt;special files&lt;/strong&gt;, which act as gateways to devices, processes, and links.&lt;/p&gt;

&lt;p&gt;This article focuses on special files only. It uses &lt;strong&gt;point-based explanations for readability&lt;/strong&gt; while keeping &lt;strong&gt;complete descriptive detail&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  1) Block Files
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;What they are&lt;/strong&gt;: Interfaces to devices that manage data in &lt;strong&gt;fixed-size chunks (blocks)&lt;/strong&gt;—commonly 512 bytes or larger—so the system can read or write a whole block at once.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Access pattern&lt;/strong&gt;: Support &lt;strong&gt;random access&lt;/strong&gt;, which lets the kernel jump directly to any block on the device without scanning earlier data—like flipping straight to page 100 in a book.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Where they live&lt;/strong&gt;: Exposed under &lt;code&gt;/dev&lt;/code&gt;, for example &lt;strong&gt;&lt;code&gt;/dev/sda&lt;/code&gt;&lt;/strong&gt; (first SATA/SCSI disk) or &lt;strong&gt;&lt;code&gt;/dev/nvme0n1&lt;/code&gt;&lt;/strong&gt; (NVMe SSD).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Why they matter&lt;/strong&gt;: Filesystems (ext4, xfs, btrfs, etc.) rely on the random-access nature of block devices to place and retrieve metadata and file content efficiently.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Common commands&lt;/strong&gt;:

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;lsblk&lt;/code&gt; — enumerate block devices in a tree view with sizes, types, and mount points.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;fdisk -l&lt;/code&gt; — inspect partition tables and partitions on attached disks.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;strong&gt;Mental model&lt;/strong&gt;:
A block device is a &lt;strong&gt;book&lt;/strong&gt;: pages (blocks) can be opened directly in any order.&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
  2) Character Files
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;What they are&lt;/strong&gt;: Interfaces to devices that send/receive data as a &lt;strong&gt;continuous stream of characters&lt;/strong&gt; rather than addressable blocks.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Access pattern&lt;/strong&gt;: &lt;strong&gt;Sequential&lt;/strong&gt; by nature; data flows in order and cannot be randomly jumped like pages in a book—more like water from a tap.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Where they live&lt;/strong&gt;: Also under &lt;code&gt;/dev&lt;/code&gt;, with common examples like &lt;strong&gt;&lt;code&gt;/dev/tty&lt;/code&gt;&lt;/strong&gt; (terminal/keyboard) and &lt;strong&gt;&lt;code&gt;/dev/null&lt;/code&gt;&lt;/strong&gt; (a sink that discards all input).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Why they matter&lt;/strong&gt;: Ideal for &lt;strong&gt;real-time I/O&lt;/strong&gt; with human interfaces (keyboards, serial ports) and virtual devices that don’t store data but still need a uniform interface.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Demonstration&lt;/strong&gt;:

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;cat /dev/tty&lt;/code&gt; — read characters typed into the terminal device.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;echo "noise" &amp;gt; /dev/null&lt;/code&gt; — write and discard output with zero storage.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;strong&gt;Mental model&lt;/strong&gt;: 
A character device is a &lt;strong&gt;tap&lt;/strong&gt;: the stream arrives in sequence and you consume it as it flows.&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
  3) Socket Files (Unix Domain Sockets)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;What they are&lt;/strong&gt;: &lt;strong&gt;IPC endpoints&lt;/strong&gt; represented as filesystem entries (usually in &lt;code&gt;/run&lt;/code&gt; or &lt;code&gt;/var/run&lt;/code&gt;) that let processes on the same host exchange messages bidirectionally.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;How they work&lt;/strong&gt;: One process &lt;strong&gt;listens&lt;/strong&gt; on a socket path; other processes &lt;strong&gt;connect&lt;/strong&gt; to it and exchange request/response data—akin to a private telephone line that stays inside the machine.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Example&lt;/strong&gt;: &lt;strong&gt;&lt;code&gt;/var/run/docker.sock&lt;/code&gt;&lt;/strong&gt; enables &lt;code&gt;docker&lt;/code&gt; CLI commands to communicate with the Docker daemon without exposing a TCP port.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Why they matter&lt;/strong&gt;: Provide low-latency, secure communication channels for &lt;strong&gt;daemons and clients&lt;/strong&gt; (database servers, system services, container runtimes) without temporary files.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Inspection&lt;/strong&gt;: &lt;code&gt;ss -x&lt;/code&gt; lists active Unix domain sockets; combine with &lt;code&gt;lsof&lt;/code&gt; to see which processes own them.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Mental model&lt;/strong&gt;: 
A socket is a &lt;strong&gt;phone line&lt;/strong&gt; between programs, not a file of stored bytes.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  4) Named Pipes (FIFOs)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;What they are&lt;/strong&gt;: Special files created with &lt;code&gt;mkfifo&lt;/code&gt; that implement &lt;strong&gt;first-in, first-out&lt;/strong&gt; byte streams between &lt;strong&gt;unrelated&lt;/strong&gt; processes via the filesystem.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Behavior&lt;/strong&gt;: One process &lt;strong&gt;writes&lt;/strong&gt;; another &lt;strong&gt;reads&lt;/strong&gt; in the same order. Data does not persist: once read, it’s gone. Writers block until a reader opens the FIFO (and vice versa) unless opened non-blocking.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Why they matter&lt;/strong&gt;: Enable &lt;strong&gt;streaming handoffs&lt;/strong&gt; and &lt;strong&gt;decoupled pipelines&lt;/strong&gt; without intermediate on-disk files—useful for glueing tools that weren’t started in the same shell pipeline.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Minimal example&lt;/strong&gt;:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  &lt;span class="nb"&gt;mkfifo &lt;/span&gt;mypipe
  &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Hello World"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; mypipe      &lt;span class="c"&gt;# Writer blocks until a reader connects&lt;/span&gt;
  &lt;span class="nb"&gt;cat&lt;/span&gt; &amp;lt; mypipe                     &lt;span class="c"&gt;# Reader receives "Hello World"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Mental model&lt;/strong&gt;: 
A FIFO is a &lt;strong&gt;tube&lt;/strong&gt; between programs; what goes in first comes out first.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  5) Links (Hard and Symbolic)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;What they are&lt;/strong&gt;: Alternative names or references that let you access the same file content (hard links) or target path (symbolic links) through different directory entries.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Hard links&lt;/strong&gt;: Create &lt;strong&gt;another directory entry&lt;/strong&gt; pointing to the &lt;strong&gt;same inode&lt;/strong&gt; and data blocks. Deleting one name does &lt;strong&gt;not&lt;/strong&gt; delete the underlying content while any hard link remains.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Symbolic (soft) links&lt;/strong&gt;: Create a small file that stores the &lt;strong&gt;target path&lt;/strong&gt;. If the target is moved or deleted, the symlink becomes &lt;strong&gt;dangling&lt;/strong&gt; and fails to resolve.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Use cases&lt;/strong&gt;: Hard links are for redundancy within the same filesystem; symlinks are for &lt;strong&gt;flexible redirection&lt;/strong&gt;, cross-filesystem pointers, and versioned paths (like &lt;code&gt;current -&amp;gt; v2.3.1&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Commands&lt;/strong&gt;:

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;ln original.txt hard.txt&lt;/code&gt; — new hard link sharing inode with &lt;code&gt;original.txt&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;ln -s original.txt soft.txt&lt;/code&gt; — symlink that resolves to &lt;code&gt;original.txt&lt;/code&gt;’s path.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;strong&gt;Mental model&lt;/strong&gt;: 
A hard link is &lt;strong&gt;another door to the same room&lt;/strong&gt;; a symlink is a &lt;strong&gt;signpost&lt;/strong&gt; pointing to a room by address.&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
  6) Identifying File Types Quickly
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;ls -l&lt;/code&gt;&lt;/strong&gt; reveals the file type via the &lt;strong&gt;first character&lt;/strong&gt; of the mode string:

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;-&lt;/code&gt; regular file, &lt;code&gt;d&lt;/code&gt; directory, &lt;code&gt;b&lt;/code&gt; block device, &lt;code&gt;c&lt;/code&gt; character device, &lt;code&gt;s&lt;/code&gt; socket, &lt;code&gt;p&lt;/code&gt; FIFO, &lt;code&gt;l&lt;/code&gt; symlink.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;strong&gt;&lt;code&gt;stat&lt;/code&gt;&lt;/strong&gt; provides detailed metadata including inode, device numbers, and link counts, which is especially helpful for distinguishing &lt;strong&gt;hard links&lt;/strong&gt; (same inode) from different files.&lt;/li&gt;

&lt;/ul&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Symbol&lt;/th&gt;
&lt;th&gt;File Type&lt;/th&gt;
&lt;th&gt;Example&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;-&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Regular file&lt;/td&gt;
&lt;td&gt;&lt;code&gt;notes.txt&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;d&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Directory&lt;/td&gt;
&lt;td&gt;&lt;code&gt;/home/user/&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;b&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Block device&lt;/td&gt;
&lt;td&gt;&lt;code&gt;/dev/sda&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;c&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Character device&lt;/td&gt;
&lt;td&gt;&lt;code&gt;/dev/tty&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;s&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Socket&lt;/td&gt;
&lt;td&gt;&lt;code&gt;/var/run/docker.sock&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;p&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Named Pipe (FIFO)&lt;/td&gt;
&lt;td&gt;&lt;code&gt;/tmp/mypipe&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;l&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Link (symlink)&lt;/td&gt;
&lt;td&gt;&lt;code&gt;shortcut → file.txt&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  7) Why Special Files Matter (Unified Power)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;API unification&lt;/strong&gt;: The same syscalls—&lt;code&gt;open&lt;/code&gt;, &lt;code&gt;read&lt;/code&gt;, &lt;code&gt;write&lt;/code&gt;, &lt;code&gt;ioctl&lt;/code&gt;, &lt;code&gt;close&lt;/code&gt;—work across devices, IPC endpoints, and regular files, which &lt;strong&gt;simplifies user-space programming&lt;/strong&gt; and tooling.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Transparency &amp;amp; portability&lt;/strong&gt;: Scripts and applications don’t need device-specific code paths; they interact with everything as if it were a file, improving &lt;strong&gt;composability&lt;/strong&gt; and &lt;strong&gt;portability&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Performance &amp;amp; ergonomics&lt;/strong&gt;: Block devices enable filesystems and fast random I/O; character devices support live streams; sockets and FIFOs enable efficient &lt;strong&gt;zero-temp-file&lt;/strong&gt; pipelines between services.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Operational clarity&lt;/strong&gt;: With &lt;code&gt;ls -l&lt;/code&gt;, &lt;code&gt;stat&lt;/code&gt;, &lt;code&gt;lsblk&lt;/code&gt;, &lt;code&gt;ss -x&lt;/code&gt;, and &lt;code&gt;lsof&lt;/code&gt;, you can &lt;strong&gt;discover, inspect, and debug&lt;/strong&gt; device access and IPC links using familiar file-centric tooling.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Final Takeaway
&lt;/h3&gt;

&lt;p&gt;Special files turn a complex operating system into a &lt;strong&gt;cohesive, scriptable environment&lt;/strong&gt;. Whether you are saving data to a disk, capturing keystrokes, streaming data across processes, or wiring services together, Linux keeps it elegant by making it all &lt;strong&gt;file operations&lt;/strong&gt;—consistently discoverable, inspectable, and automatable.&lt;/p&gt;

</description>
      <category>linux</category>
      <category>devops</category>
      <category>beginners</category>
    </item>
    <item>
      <title>VM Networking Demystified: NAT, Bridged, Host-Only, Port Forwarding, and Multi-VM Private Networks</title>
      <dc:creator>Naval Kishor Upadhyay</dc:creator>
      <pubDate>Sun, 07 Sep 2025 11:28:50 +0000</pubDate>
      <link>https://dev.to/naval_upadhyay/vm-networking-demystified-nat-bridged-host-only-port-forwarding-and-multi-vm-private-networks-1hp8</link>
      <guid>https://dev.to/naval_upadhyay/vm-networking-demystified-nat-bridged-host-only-port-forwarding-and-multi-vm-private-networks-1hp8</guid>
      <description>&lt;p&gt;When you spin up a virtual machine (VM) in VirtualBox, VMware, or Vagrant, one of the first decisions you face is: &lt;strong&gt;How should this VM connect to the network?&lt;/strong&gt;  &lt;/p&gt;

&lt;p&gt;Do you want it to access the internet? Should your host computer see it? Should two VMs talk to each other? Should others on your LAN be able to reach it like a normal PC?  &lt;/p&gt;

&lt;p&gt;This is where VM networking modes — &lt;strong&gt;NAT, NAT Network, Bridged, and Host-Only&lt;/strong&gt; — come into play. And when you mix in &lt;strong&gt;port forwarding&lt;/strong&gt; and &lt;strong&gt;multi-VM setups&lt;/strong&gt;, things can get confusing fast.  &lt;/p&gt;

&lt;p&gt;This article will cut through that confusion and explain, in simple but thorough terms, how each mode works, when to use it, and how to combine them.  &lt;/p&gt;




&lt;h2&gt;
  
  
  1. Why VM Networking Matters
&lt;/h2&gt;

&lt;p&gt;A virtual machine is like a computer inside your computer. But unlike physical computers, it doesn’t automatically have a network connection.  &lt;/p&gt;

&lt;p&gt;Depending on your needs, you might want your VM to:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Download software updates from the internet.
&lt;/li&gt;
&lt;li&gt;Act like a server that’s reachable from other devices on your LAN.
&lt;/li&gt;
&lt;li&gt;Stay isolated, but still be accessible from your host machine.
&lt;/li&gt;
&lt;li&gt;Communicate with other VMs in a private lab environment.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The right networking mode ensures you get exactly what you need — no more, no less.  &lt;/p&gt;




&lt;h2&gt;
  
  
  2. The Core Networking Modes Explained
&lt;/h2&gt;

&lt;p&gt;Let’s go through the four main networking options you’ll encounter in most virtualization tools.&lt;/p&gt;




&lt;h3&gt;
  
  
  2.1 NAT (Network Address Translation)
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;How it works:&lt;/strong&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The VM “hides” behind your host’s IP address.
&lt;/li&gt;
&lt;li&gt;From the outside world, it looks like the traffic is coming from the host.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Capabilities:&lt;/strong&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Internet Access:&lt;/strong&gt; ✅ Yes (via host’s connection).
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Inbound Connections:&lt;/strong&gt; ❌ No (blocked unless you configure port forwarding).
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;VM ↔ VM Communication:&lt;/strong&gt; ❌ No (each VM gets isolated behind NAT).
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Best Use Case:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Quick internet access for downloading packages or running updates, when you don’t need external access to the VM.  &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%2Fbbt8i79aurah3xi5gzwm.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%2Fbbt8i79aurah3xi5gzwm.png" alt=" " width="800" height="195"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  2.2 NAT Network
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;How it works:&lt;/strong&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Similar to NAT, but all VMs connected to the same NAT network share a private subnet.
&lt;/li&gt;
&lt;li&gt;They can talk to each other while still having internet access.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Capabilities:&lt;/strong&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Internet Access:&lt;/strong&gt; ✅ Yes.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Inbound Connections:&lt;/strong&gt; ❌ No (unless port forwarding).
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;VM ↔ VM Communication:&lt;/strong&gt; ✅ Yes (within the NAT network).
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Best Use Case:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
When you’re simulating multi-VM environments (like app server + database) that still need to access the internet.  &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%2F6j65mv00po6dz6romzu2.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%2F6j65mv00po6dz6romzu2.png" alt=" " width="800" height="175"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  2.3 Bridged Adapter
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;How it works:&lt;/strong&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The VM connects directly to your physical network, just like another laptop or phone.
&lt;/li&gt;
&lt;li&gt;Your router gives it its own IP address.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Capabilities:&lt;/strong&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Internet Access:&lt;/strong&gt; ✅ Yes.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Inbound Connections:&lt;/strong&gt; ✅ Yes (VM has its own IP on LAN).
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;VM ↔ VM Communication:&lt;/strong&gt; ✅ Yes (they’re all peers on the LAN).
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Best Use Case:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
When you want your VM to act like a real physical machine on your network — for example, testing a web server accessible to other devices.  &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%2Fqsulwhf5qvzfvtd3b0vv.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%2Fqsulwhf5qvzfvtd3b0vv.png" alt=" " width="800" height="652"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  2.4 Host-Only Network
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;How it works:&lt;/strong&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Creates a completely private network between the host and VMs.
&lt;/li&gt;
&lt;li&gt;No connection to the outside world.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Capabilities:&lt;/strong&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Internet Access:&lt;/strong&gt; ❌ No (unless paired with another adapter).
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Inbound Connections:&lt;/strong&gt; ✅ Yes, from host.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;VM ↔ VM Communication:&lt;/strong&gt; ✅ Yes (inside the private network).
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Best Use Case:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
For isolated test labs where you don’t want VMs exposed to the internet. Perfect for experimenting without risk.  &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Diagram:&lt;/strong&gt;&lt;br&gt;&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%2Fbn2cog8uthjtehoayctj.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%2Fbn2cog8uthjtehoayctj.png" alt=" " width="800" height="307"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  3. Port Forwarding: Accessing VMs Without Public IPs
&lt;/h2&gt;

&lt;p&gt;With NAT and NAT Network, your VM doesn’t have a public-facing IP. That means you can’t just &lt;code&gt;ssh user@vm_ip&lt;/code&gt; from your host or another computer.  &lt;/p&gt;

&lt;p&gt;This is where &lt;strong&gt;port forwarding&lt;/strong&gt; comes in. It’s like a tunnel through the host machine:  &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Set up forwarding&lt;/strong&gt;: Map a host port (e.g., &lt;code&gt;2222&lt;/code&gt;) to the VM’s port (e.g., &lt;code&gt;22&lt;/code&gt; for SSH).
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Client connects&lt;/strong&gt;: From your laptop, run &lt;code&gt;ssh -p 2222 user@host_ip&lt;/code&gt;.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Host forwards&lt;/strong&gt;: The host takes traffic from port &lt;code&gt;2222&lt;/code&gt; and forwards it to the VM’s internal IP on port &lt;code&gt;22&lt;/code&gt;.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;VM responds&lt;/strong&gt;: You’re inside the VM as if it had a public IP.
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Diagram:&lt;/strong&gt;  &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%2Fsphnep9svmtobb109rxm.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%2Fsphnep9svmtobb109rxm.png" alt=" " width="800" height="543"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why it matters:&lt;/strong&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Lets you connect securely to VMs without exposing them directly to your network.
&lt;/li&gt;
&lt;li&gt;Essential for NAT and NAT Network setups.
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  4. Connecting Multiple VMs Together
&lt;/h2&gt;

&lt;p&gt;Sometimes, one VM isn’t enough. Maybe you want a &lt;strong&gt;web server&lt;/strong&gt; talking to a &lt;strong&gt;database server&lt;/strong&gt;, or a &lt;strong&gt;load balancer&lt;/strong&gt; managing multiple &lt;strong&gt;app servers&lt;/strong&gt;.  &lt;/p&gt;

&lt;p&gt;Here’s how you can do it:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;NAT Network&lt;/strong&gt; → Best option if you want VMs to communicate &lt;strong&gt;and&lt;/strong&gt; reach the internet.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Host-Only Network&lt;/strong&gt; → Good for completely isolated labs, where internet access is not required.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Bridged Network&lt;/strong&gt; → Works if you want your VMs to behave like independent physical devices on your LAN.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Example Scenario:&lt;/strong&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;VM1 = Web Server&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;VM2 = Database Server&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Both attached to a &lt;strong&gt;NAT Network&lt;/strong&gt;.
&lt;/li&gt;
&lt;li&gt;VM1 can query VM2, VM2 can respond, and both can still download updates from the internet.
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  5. Quick Comparison Table
&lt;/h2&gt;

&lt;p&gt;Here’s the cheat sheet you’ll want to bookmark:  &lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Mode&lt;/th&gt;
&lt;th&gt;Internet Access&lt;/th&gt;
&lt;th&gt;VM ↔ VM&lt;/th&gt;
&lt;th&gt;VM ↔ Host&lt;/th&gt;
&lt;th&gt;Reachable from LAN&lt;/th&gt;
&lt;th&gt;Best Use Case&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;NAT&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;✅ Yes&lt;/td&gt;
&lt;td&gt;❌ No&lt;/td&gt;
&lt;td&gt;⚠️ Only via Port Forwarding&lt;/td&gt;
&lt;td&gt;❌ No&lt;/td&gt;
&lt;td&gt;Single VM with safe internet&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;NAT Network&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;✅ Yes&lt;/td&gt;
&lt;td&gt;✅ Yes&lt;/td&gt;
&lt;td&gt;✅ Yes (with setup)&lt;/td&gt;
&lt;td&gt;❌ No&lt;/td&gt;
&lt;td&gt;Multi-VM labs + internet&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Bridged&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;✅ Yes&lt;/td&gt;
&lt;td&gt;✅ Yes&lt;/td&gt;
&lt;td&gt;✅ Yes&lt;/td&gt;
&lt;td&gt;✅ Yes&lt;/td&gt;
&lt;td&gt;Realistic server testing&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Host-Only&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;❌ No&lt;/td&gt;
&lt;td&gt;✅ Yes&lt;/td&gt;
&lt;td&gt;✅ Yes&lt;/td&gt;
&lt;td&gt;❌ No&lt;/td&gt;
&lt;td&gt;Isolated test setups&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  6. Wrapping It All Up
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;NAT&lt;/strong&gt; → Great for single VMs needing internet.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;NAT Network&lt;/strong&gt; → Perfect for multi-VM setups with internet.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Bridged&lt;/strong&gt; → Best when your VM should act like a real device on your LAN.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Host-Only&lt;/strong&gt; → Ideal for isolated environments.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Port Forwarding&lt;/strong&gt; → The secret sauce to access NAT’d VMs.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Private Networks&lt;/strong&gt; → Enable complex multi-VM topologies without exposing them.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Once you understand these modes, you can build powerful &lt;strong&gt;virtual labs&lt;/strong&gt; on your laptop that mimic real-world networks — whether you’re learning DevOps, testing servers, or simulating production environments.  &lt;/p&gt;

</description>
      <category>webdev</category>
      <category>devops</category>
      <category>networking</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Certificates and Digital Trust: Why the Web Believes a Website</title>
      <dc:creator>Naval Kishor Upadhyay</dc:creator>
      <pubDate>Sun, 07 Sep 2025 11:08:22 +0000</pubDate>
      <link>https://dev.to/naval_upadhyay/certificates-and-digital-trust-why-the-web-believes-a-website-4771</link>
      <guid>https://dev.to/naval_upadhyay/certificates-and-digital-trust-why-the-web-believes-a-website-4771</guid>
      <description>&lt;p&gt;Every time you see the little padlock icon in your browser, you’re relying on one of the most important building blocks of the internet: &lt;strong&gt;digital certificates&lt;/strong&gt;. They are what convince your browser that a website really is who it claims to be, and not an impostor.  &lt;/p&gt;

&lt;p&gt;Let’s unpack how they work, why they matter, and what could go wrong without them.  &lt;/p&gt;




&lt;h2&gt;
  
  
  1. The problem: who do you trust on the internet?
&lt;/h2&gt;

&lt;p&gt;Imagine you want to log in to your bank’s website. You type the familiar address:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://mybank.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But how do you know the site you’re connecting to is actually your bank, and not a clever attacker pretending to be it?  &lt;/p&gt;

&lt;p&gt;The problem: &lt;strong&gt;anyone can set up a server and claim to be “mybank.com.”&lt;/strong&gt; Without a trust system, your browser couldn’t tell the difference.  &lt;/p&gt;




&lt;h2&gt;
  
  
  2. Enter certificates
&lt;/h2&gt;

&lt;p&gt;A &lt;strong&gt;digital certificate&lt;/strong&gt; is like an official ID card for a website.  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It says &lt;em&gt;“this public key belongs to this domain (e.g., mybank.com).”&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;It is issued and signed by a trusted authority (like an internet notary).
&lt;/li&gt;
&lt;li&gt;Your browser checks this certificate before it allows the secure connection.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Without certificates, HTTPS (the “S” in the padlock) would be meaningless — because anyone could pretend to be anyone.  &lt;/p&gt;




&lt;h2&gt;
  
  
  3. The role of Certificate Authorities (CAs)
&lt;/h2&gt;

&lt;p&gt;Certificates are issued by organizations called &lt;strong&gt;Certificate Authorities (CAs)&lt;/strong&gt;.  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A CA verifies the identity of the website owner (using different levels of checks).
&lt;/li&gt;
&lt;li&gt;It then issues a certificate binding the website’s &lt;strong&gt;domain name&lt;/strong&gt; to its &lt;strong&gt;public key&lt;/strong&gt;.
&lt;/li&gt;
&lt;li&gt;This certificate is &lt;strong&gt;digitally signed&lt;/strong&gt; by the CA’s private key.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Your browser comes preloaded with a list of “trusted CAs.” If a website’s certificate is signed by one of those CAs, the browser trusts it.  &lt;/p&gt;

&lt;p&gt;This creates a &lt;strong&gt;chain of trust&lt;/strong&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  4. How your browser builds trust in a website
&lt;/h2&gt;

&lt;p&gt;When you type &lt;code&gt;https://mybank.com&lt;/code&gt;, a lot happens before the padlock appears. The browser doesn’t just take the server’s word for it — it carefully checks and challenges the certificate before declaring the connection secure.  &lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Website presents its certificate
&lt;/h3&gt;

&lt;p&gt;The server sends your browser its &lt;strong&gt;digital certificate&lt;/strong&gt;. This document includes:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the website’s domain name (&lt;code&gt;mybank.com&lt;/code&gt;),
&lt;/li&gt;
&lt;li&gt;the website’s &lt;strong&gt;public key&lt;/strong&gt;,
&lt;/li&gt;
&lt;li&gt;validity dates,
&lt;/li&gt;
&lt;li&gt;and the &lt;strong&gt;signature of the Certificate Authority (CA)&lt;/strong&gt; that issued it.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;At this point, the browser has the certificate, but it still needs to decide whether to &lt;strong&gt;trust it&lt;/strong&gt;.  &lt;/p&gt;




&lt;h3&gt;
  
  
  Step 2: Browser validates the certificate
&lt;/h3&gt;

&lt;p&gt;The browser runs several checks:  &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Signature check&lt;/strong&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Every certificate is signed by the CA’s &lt;strong&gt;private key&lt;/strong&gt;.
&lt;/li&gt;
&lt;li&gt;The browser uses the CA’s &lt;strong&gt;public key&lt;/strong&gt; (already pre-installed and trusted) to verify this signature.
&lt;/li&gt;
&lt;li&gt;If the signature matches, it proves the certificate was really issued by that CA and hasn’t been altered.
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Chain of trust&lt;/strong&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Certificates are often issued by an &lt;strong&gt;Intermediate CA&lt;/strong&gt;, which itself was signed by a &lt;strong&gt;Root CA&lt;/strong&gt;.
&lt;/li&gt;
&lt;li&gt;The browser follows the chain step by step:

&lt;ul&gt;
&lt;li&gt;Website certificate → signed by Intermediate CA.
&lt;/li&gt;
&lt;li&gt;Intermediate CA certificate → signed by Root CA.
&lt;/li&gt;
&lt;li&gt;Root CA → already trusted in the browser.
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;At each step, the parent’s public key is used to verify the child’s signature.
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Domain and validity&lt;/strong&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The certificate must list the exact domain you typed (&lt;code&gt;mybank.com&lt;/code&gt;, not &lt;code&gt;evilbank.com&lt;/code&gt;).
&lt;/li&gt;
&lt;li&gt;It must be within its valid date range and not revoked by the CA.
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Only if all these checks pass does the browser trust the certificate.  &lt;/p&gt;




&lt;h3&gt;
  
  
  Step 3: Server proves it owns the private key
&lt;/h3&gt;

&lt;p&gt;Now the browser knows the certificate is genuine, but there’s still one crucial question:  &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Does this server actually own the &lt;strong&gt;private key&lt;/strong&gt; that matches the public key in the certificate?  &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;To confirm:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The browser sends a small piece of test data (or challenge).
&lt;/li&gt;
&lt;li&gt;Only the real server, with the matching private key, can respond correctly by signing or decrypting it.
&lt;/li&gt;
&lt;li&gt;If the response checks out, the browser is sure it’s talking to the true holder of the certificate, not an impostor who copied it.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This step prevents attackers from simply stealing a certificate file and using it on their own servers. Without the private key, the certificate is useless.  &lt;/p&gt;




&lt;h3&gt;
  
  
  Step 4: Browser and server agree on a session key
&lt;/h3&gt;

&lt;p&gt;With trust established, the final step is to set up a &lt;strong&gt;shared session key&lt;/strong&gt; for the actual conversation.  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The browser generates a random, one-time &lt;strong&gt;session key&lt;/strong&gt;.
&lt;/li&gt;
&lt;li&gt;It encrypts this session key with the website’s &lt;strong&gt;public key&lt;/strong&gt; (from the certificate).
&lt;/li&gt;
&lt;li&gt;The server uses its private key to decrypt it.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now both sides know the session key, but no one else does.  &lt;/p&gt;

&lt;p&gt;From this point on:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;All communication (pages, logins, payments) is protected with &lt;strong&gt;symmetric encryption&lt;/strong&gt; using that session key.
&lt;/li&gt;
&lt;li&gt;Symmetric encryption is much faster, making it ideal for ongoing data transfer.
&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  End result: trusted, encrypted session
&lt;/h3&gt;

&lt;p&gt;By combining these steps — validating the certificate, confirming the server’s private key, and agreeing on a session key — your browser can finally show the padlock. This signals:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You’re connected to the &lt;strong&gt;right website&lt;/strong&gt;.
&lt;/li&gt;
&lt;li&gt;The connection is &lt;strong&gt;private and secure&lt;/strong&gt;.
&lt;/li&gt;
&lt;li&gt;All further traffic will be encrypted efficiently.
&lt;/li&gt;
&lt;/ul&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%2Fdvaxk9kiwlmfodwuhjdj.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%2Fdvaxk9kiwlmfodwuhjdj.png" alt=" " width="800" height="651"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  5. Levels of trust in certificates
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;DV (Domain Validation)&lt;/strong&gt; → Confirms domain control.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;OV (Organization Validation)&lt;/strong&gt; → Confirms legal entity.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;EV (Extended Validation)&lt;/strong&gt; → Strongest checks, often used by banks.
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  6. What happens if certificates didn’t exist?
&lt;/h2&gt;

&lt;p&gt;Without certificates, you could be tricked into encrypting traffic with an attacker’s key. Encryption alone would not protect you — you’d be secure &lt;em&gt;with the wrong person&lt;/em&gt;.  &lt;/p&gt;

&lt;p&gt;Certificates close this gap by binding the website’s domain to its public key, and by requiring the server to prove ownership of the matching private key.  &lt;/p&gt;




&lt;h2&gt;
  
  
  7. Weak points in the system
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Compromised CA&lt;/strong&gt; → Fake certificates could be issued.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Expired certificates&lt;/strong&gt; → Users see warnings until renewed.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;User ignoring warnings&lt;/strong&gt; → Clicking “Proceed anyway” breaks the trust model.
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  8. Everyday impact
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Online banking
&lt;/li&gt;
&lt;li&gt;Shopping
&lt;/li&gt;
&lt;li&gt;Messaging apps and APIs
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All rely on certificate validation and the website’s public key to prove authenticity and protect data.  &lt;/p&gt;




&lt;h2&gt;
  
  
  9. Key takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Certificates = digital ID cards for websites.
&lt;/li&gt;
&lt;li&gt;CAs = trusted notaries that issue them.
&lt;/li&gt;
&lt;li&gt;Browsers validate certificates by checking signatures with CA public keys and walking the chain of trust.
&lt;/li&gt;
&lt;li&gt;The website must also prove it controls the &lt;strong&gt;matching private key&lt;/strong&gt;.
&lt;/li&gt;
&lt;li&gt;A session key is then agreed and used for fast symmetric encryption.
&lt;/li&gt;
&lt;li&gt;Without this process, HTTPS would not provide real trust.
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>webdev</category>
      <category>security</category>
      <category>beginners</category>
    </item>
    <item>
      <title>How SSH Authentication Really Works</title>
      <dc:creator>Naval Kishor Upadhyay</dc:creator>
      <pubDate>Fri, 05 Sep 2025 15:40:38 +0000</pubDate>
      <link>https://dev.to/naval_upadhyay/how-ssh-authentication-really-works-16aj</link>
      <guid>https://dev.to/naval_upadhyay/how-ssh-authentication-really-works-16aj</guid>
      <description>&lt;p&gt;SSH (Secure Shell) is the tool that engineers use to log into servers safely. It solves two big problems:  &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Privacy&lt;/strong&gt; — everything you type and receive is encrypted so outsiders can’t read it.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Identity&lt;/strong&gt; — the server knows it’s really you, and you know it’s really the server.
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Let’s walk through how SSH makes this possible, step by step.  &lt;/p&gt;




&lt;h2&gt;
  
  
  1. The problem SSH solves
&lt;/h2&gt;

&lt;p&gt;Without protection, your password or commands would travel across the network in plain text. Anyone listening could steal them. SSH was built to prevent this.  &lt;/p&gt;

&lt;p&gt;It guarantees:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Encryption&lt;/strong&gt; so the session can’t be spied on.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Authentication&lt;/strong&gt; so access is only granted to the right person.
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  2. Your digital identity: SSH keys
&lt;/h2&gt;

&lt;p&gt;SSH avoids sending passwords by using a &lt;strong&gt;pair of keys&lt;/strong&gt;:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Private key&lt;/strong&gt; → stored on your laptop, never shared.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Public key&lt;/strong&gt; → copied to the server.
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  3. How the login actually works
&lt;/h2&gt;

&lt;p&gt;Here’s what happens when you type &lt;code&gt;ssh user@server&lt;/code&gt;:  &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Connection starts&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Client and server set up a secure channel so no one can listen in.  &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Server identity check&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
The server shows its own “host key.” Your computer checks it against saved records to ensure you’re not talking to an impostor.  &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Authentication&lt;/strong&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The server finds your public key in its records.
&lt;/li&gt;
&lt;li&gt;It sends you a random &lt;strong&gt;challenge&lt;/strong&gt;: “Prove you own the private key.”
&lt;/li&gt;
&lt;li&gt;Your computer signs this challenge with your &lt;strong&gt;private key&lt;/strong&gt;.
&lt;/li&gt;
&lt;li&gt;The server uses your &lt;strong&gt;public key&lt;/strong&gt; to verify the signature.
&lt;/li&gt;
&lt;li&gt;If it matches, you are authenticated — without ever sending a password.
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&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%2Frsltxlehhtdo9c14nebi.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%2Frsltxlehhtdo9c14nebi.png" alt=" " width="800" height="581"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  4. Deep dive: verifying the signature
&lt;/h2&gt;

&lt;p&gt;This is the heart of SSH authentication — how the server proves you really have the private key.  &lt;/p&gt;

&lt;p&gt;The server already has:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the &lt;strong&gt;public key&lt;/strong&gt; you uploaded earlier
&lt;/li&gt;
&lt;li&gt;the fresh &lt;strong&gt;challenge&lt;/strong&gt; it just generated
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Your laptop produces a &lt;strong&gt;signature&lt;/strong&gt; of that challenge using your private key.&lt;br&gt;&lt;br&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;   Signature: MEQCIF6QwG1W84yF8Lk98K1F5...aYFJ2kAbQIgJj4H
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The server takes the challenge, your signature, and your public key, and runs a check:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If the signature correctly matches the challenge with that public key → ✅ you must own the private key.
&lt;/li&gt;
&lt;li&gt;If not → ❌ login is denied.
&lt;/li&gt;
&lt;/ul&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%2Ffbmrk2zsuix1o8bq2f8s.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%2Ffbmrk2zsuix1o8bq2f8s.png" alt=" " width="800" height="192"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Why this works:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Only the correct private key can produce a valid signature for that challenge.
&lt;/li&gt;
&lt;li&gt;The challenge is random each time, so an old signature can’t be replayed.
&lt;/li&gt;
&lt;li&gt;The private key never leaves your laptop, so there’s nothing to steal in transit.
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  5. Why this is secure
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;No password is sent over the network&lt;/strong&gt; — nothing reusable to steal.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The private key stays with you&lt;/strong&gt; — only a mathematical proof (signature) is shared.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Replay attacks are blocked&lt;/strong&gt; — each login uses a fresh challenge.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The server itself is verified&lt;/strong&gt; — SSH warns you if a server’s identity suddenly changes.
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  6. Benefits in practice
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Safer than passwords&lt;/strong&gt; — prevents brute-force guessing and credential theft.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Easy to manage&lt;/strong&gt; — add/remove public keys to control access.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Automation-friendly&lt;/strong&gt; — scripts and systems can log in without storing passwords.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Scales to teams&lt;/strong&gt; — each engineer gets their own key; revoking access is as simple as removing one line.
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  7. What can go wrong
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;If your &lt;strong&gt;private key file&lt;/strong&gt; is stolen and not protected by a passphrase, an attacker can impersonate you.
&lt;/li&gt;
&lt;li&gt;If you ignore SSH’s warning about a &lt;strong&gt;changed server identity&lt;/strong&gt;, you may connect to an impostor.
&lt;/li&gt;
&lt;li&gt;If teams &lt;strong&gt;share keys&lt;/strong&gt;, you lose accountability — you can’t tell who did what.
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Key takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;SSH doesn’t rely on sending passwords — it proves identity with keys and signatures.
&lt;/li&gt;
&lt;li&gt;The server challenges you, and your private key signs the challenge.
&lt;/li&gt;
&lt;li&gt;If the server can verify the signature with your public key, it knows it’s really you.
&lt;/li&gt;
&lt;li&gt;After login, all communication is encrypted with a fast shared key.
&lt;/li&gt;
&lt;li&gt;The system is secure because the private key never leaves your device.
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>beginners</category>
      <category>security</category>
    </item>
    <item>
      <title>Symmetric vs Asymmetric Encryption — Explained Clearly</title>
      <dc:creator>Naval Kishor Upadhyay</dc:creator>
      <pubDate>Thu, 04 Sep 2025 14:27:43 +0000</pubDate>
      <link>https://dev.to/naval_upadhyay/symmetric-vs-asymmetric-encryption-explained-clearly-gp5</link>
      <guid>https://dev.to/naval_upadhyay/symmetric-vs-asymmetric-encryption-explained-clearly-gp5</guid>
      <description>&lt;h1&gt;
  
  
  Symmetric vs Asymmetric Encryption — Explained Clearly
&lt;/h1&gt;

&lt;p&gt;Encryption is like putting your information into a locked box before sending it. Only the person with the right key can open the box and read what’s inside. This is how we protect private data when it travels over the internet or sits on your computer.  &lt;/p&gt;

&lt;p&gt;But not all locks and keys work the same way. There are &lt;strong&gt;two major types of encryption&lt;/strong&gt;:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Symmetric encryption&lt;/strong&gt; — one key does both the locking and unlocking.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Asymmetric encryption&lt;/strong&gt; — two different but related keys work together: one locks, the other unlocks.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Both are essential to digital security. Let’s break them down step by step.  &lt;/p&gt;




&lt;h2&gt;
  
  
  1. Symmetric encryption: one key, two uses
&lt;/h2&gt;

&lt;p&gt;Think of a safe with a single key.  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If you want to lock something inside, you use that key.
&lt;/li&gt;
&lt;li&gt;If your friend wants to open it, they need the exact same key.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That’s symmetric encryption: &lt;strong&gt;the same key is used to scramble (encrypt) and unscramble (decrypt) information&lt;/strong&gt;.  &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%2Ft61xm15yyimzwggeupfn.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%2Ft61xm15yyimzwggeupfn.png" alt=" " width="800" height="71"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Why it’s useful
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Fast and efficient&lt;/strong&gt; → great for protecting large amounts of data.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Simple to understand&lt;/strong&gt; → one shared secret does the job.
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  The big challenge: key distribution
&lt;/h3&gt;

&lt;p&gt;Both people need the same key. But how do you give someone that key &lt;strong&gt;without anyone else seeing it&lt;/strong&gt;?  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If you send it by email → a hacker reading your email now has the key.
&lt;/li&gt;
&lt;li&gt;If you tell it over the phone → someone listening in now has the key.
&lt;/li&gt;
&lt;li&gt;If the key is leaked even once, all the information protected by it can be read.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is called the &lt;strong&gt;key distribution problem&lt;/strong&gt;. It’s the main weakness of symmetric encryption.  &lt;/p&gt;




&lt;h2&gt;
  
  
  2. Asymmetric encryption: two keys, two roles
&lt;/h2&gt;

&lt;p&gt;Symmetric encryption struggles with sharing the key. That’s where &lt;strong&gt;asymmetric encryption&lt;/strong&gt; comes in. It uses a &lt;strong&gt;key pair&lt;/strong&gt;:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A &lt;strong&gt;public key&lt;/strong&gt; → can be shared with everyone.
&lt;/li&gt;
&lt;li&gt;A &lt;strong&gt;private key&lt;/strong&gt; → kept secret, only the owner should have it.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The magic is:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If you lock something with the &lt;strong&gt;public key&lt;/strong&gt;, only the matching &lt;strong&gt;private key&lt;/strong&gt; can unlock it.
&lt;/li&gt;
&lt;li&gt;And if you “lock” (sign) something with the &lt;strong&gt;private key&lt;/strong&gt;, anyone with the &lt;strong&gt;public key&lt;/strong&gt; can check it really came from you.
&lt;/li&gt;
&lt;/ul&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%2F1s8rea7mzxbgjatcl5dh.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%2F1s8rea7mzxbgjatcl5dh.png" alt=" " width="800" height="85"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Why it’s useful
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;No need to secretly send the key&lt;/strong&gt; → you can publish your public key, and people can still send you secrets safely.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Can prove identity&lt;/strong&gt; → by using private key signatures, you can prove identity and ensure integrity.
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Weakness
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Slower&lt;/strong&gt; → not efficient for encrypting large amounts of data.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Trust issue&lt;/strong&gt; → people need to be sure that the public key they got is really yours, not an attacker’s.
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  3. Digital signatures: proving identity and integrity
&lt;/h2&gt;

&lt;p&gt;One of the most powerful things you can do with asymmetric keys is create a &lt;strong&gt;digital signature&lt;/strong&gt;.  &lt;/p&gt;

&lt;p&gt;Think of it like signing a contract:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Only you can produce your handwritten signature.
&lt;/li&gt;
&lt;li&gt;Others can check the signature matches yours.
&lt;/li&gt;
&lt;li&gt;If the contract is altered, the signature no longer matches.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In the digital world:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You use your &lt;strong&gt;private key&lt;/strong&gt; to sign data.
&lt;/li&gt;
&lt;li&gt;Anyone with your &lt;strong&gt;public key&lt;/strong&gt; can verify the signature.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This proves:  &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Authenticity&lt;/strong&gt; → the data really came from you.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Integrity&lt;/strong&gt; → the data hasn’t been tampered with.
&lt;/li&gt;
&lt;/ol&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%2Fkewhmnb62ctvgogt8hze.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%2Fkewhmnb62ctvgogt8hze.png" alt=" " width="800" height="248"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;⚠️ &lt;strong&gt;Important:&lt;/strong&gt; a signature does &lt;strong&gt;not&lt;/strong&gt; hide the message — it only proves who sent it and that it hasn’t changed. If you also want secrecy, you combine with encryption.  &lt;/p&gt;




&lt;h2&gt;
  
  
  4. How the two worlds work together
&lt;/h2&gt;

&lt;p&gt;Modern systems don’t pick one or the other — they combine both:  &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Asymmetric encryption&lt;/strong&gt; (public/private keys) is used to &lt;strong&gt;safely share a secret key&lt;/strong&gt; and to prove identity with signatures.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Symmetric encryption&lt;/strong&gt; then takes over to encrypt the actual data, because it’s much faster.
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Example: HTTPS (the padlock in your browser).  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Step 1: Your browser checks the website’s &lt;strong&gt;certificate&lt;/strong&gt; (which contains a public key).
&lt;/li&gt;
&lt;li&gt;Step 2: The website proves it owns the private key by using signatures.
&lt;/li&gt;
&lt;li&gt;Step 3: Browser and server agree on a shared &lt;strong&gt;session key&lt;/strong&gt;.
&lt;/li&gt;
&lt;li&gt;Step 4: All data (your login, credit card number, etc.) is now encrypted with &lt;strong&gt;symmetric encryption&lt;/strong&gt; for speed.
&lt;/li&gt;
&lt;/ul&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%2Fosvkwtn3x01rw50clmj3.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%2Fosvkwtn3x01rw50clmj3.png" alt=" " width="800" height="644"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  5. Strengths side by side
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Aspect&lt;/th&gt;
&lt;th&gt;Symmetric Encryption&lt;/th&gt;
&lt;th&gt;Asymmetric Encryption&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Keys&lt;/td&gt;
&lt;td&gt;One shared secret key&lt;/td&gt;
&lt;td&gt;Key pair: public (share) &amp;amp; private (keep)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Speed&lt;/td&gt;
&lt;td&gt;Very fast&lt;/td&gt;
&lt;td&gt;Slower&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Key exchange&lt;/td&gt;
&lt;td&gt;Hard to do securely&lt;/td&gt;
&lt;td&gt;Easy: just share public key&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Identity &amp;amp; authenticity&lt;/td&gt;
&lt;td&gt;Not built-in&lt;/td&gt;
&lt;td&gt;Possible with digital signatures&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Best use case&lt;/td&gt;
&lt;td&gt;Bulk data encryption&lt;/td&gt;
&lt;td&gt;Safe key exchange &amp;amp; identity proof&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  6. Key takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Symmetric encryption&lt;/strong&gt; = one shared key, fast, but hard to share securely.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Asymmetric encryption&lt;/strong&gt; = public/private key pair, slower, but solves key sharing and enables digital signatures.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Digital signatures&lt;/strong&gt; = use the private key to prove identity and protect integrity.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Real-world security&lt;/strong&gt; = combine both: asymmetric for trust and key exchange, symmetric for speed and protecting actual data.
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>security</category>
      <category>beginners</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Web Servers and Hosting Fundamentals: From Static Pages to Dynamic Applications</title>
      <dc:creator>Naval Kishor Upadhyay</dc:creator>
      <pubDate>Thu, 04 Sep 2025 13:44:59 +0000</pubDate>
      <link>https://dev.to/naval_upadhyay/web-servers-and-hosting-fundamentals-from-static-pages-to-dynamic-applications-3347</link>
      <guid>https://dev.to/naval_upadhyay/web-servers-and-hosting-fundamentals-from-static-pages-to-dynamic-applications-3347</guid>
      <description>&lt;p&gt;When you open a browser and type in a web address, a whole chain of events takes place behind the scenes before a page finally appears on your screen. At the heart of this process are web servers, application servers, frameworks, and the models that govern how websites deliver content. Understanding these building blocks is essential for anyone who wants to grasp how the modern web actually works.  &lt;/p&gt;




&lt;h2&gt;
  
  
  What Exactly is a Web Server?
&lt;/h2&gt;

&lt;p&gt;At its core, a web server is a piece of software that listens for requests from clients (usually browsers) and responds with content. This content might be something as simple as an HTML file or as complex as a dynamically generated dashboard.  &lt;/p&gt;

&lt;p&gt;There are two ways to think about web servers: software and hardware. A &lt;strong&gt;software web server&lt;/strong&gt; is a program like Apache HTTP Server, Nginx, or Microsoft IIS. These programs handle requests, process headers, serve files, and manage logging. A &lt;strong&gt;hardware web server&lt;/strong&gt;, on the other hand, refers to the physical machine that runs this software.  &lt;/p&gt;

&lt;p&gt;While modern cloud environments blur this distinction — since your “server” might be a virtual machine or even a container — the logic remains the same: a web server listens, interprets, and responds.  &lt;/p&gt;




&lt;h2&gt;
  
  
  Static vs Dynamic Websites
&lt;/h2&gt;

&lt;p&gt;To understand how servers deliver content, it helps to look at the difference between static and dynamic websites.  &lt;/p&gt;

&lt;p&gt;A &lt;strong&gt;static website&lt;/strong&gt; is the simpler of the two. Each page is pre-built and stored as a file on the server. When a client requests the page, the server simply delivers the file as-is. Nothing changes unless the developer edits and redeploys the files. This makes static sites extremely fast and reliable, but limited in functionality. They are great for personal portfolios, documentation, or informational company pages.  &lt;/p&gt;

&lt;p&gt;A &lt;strong&gt;dynamic website&lt;/strong&gt;, in contrast, generates content on demand. Instead of serving pre-written files, the server executes code — written in languages like PHP, Python, or Ruby — to build the page on the fly. If you log into an e-commerce store and see your personal order history, that content is being generated dynamically. The server retrieves your data from a database, injects it into a template, and delivers a personalized page.  &lt;/p&gt;




&lt;h2&gt;
  
  
  Web Server vs Application Server: The Key Difference
&lt;/h2&gt;

&lt;p&gt;Although the terms are often used interchangeably, &lt;strong&gt;web servers&lt;/strong&gt; and &lt;strong&gt;application servers&lt;/strong&gt; are not the same thing. They serve different but complementary roles.  &lt;/p&gt;

&lt;p&gt;A &lt;strong&gt;web server&lt;/strong&gt; is optimized for delivering static files quickly. It is like a skilled librarian who instantly finds and hands you a book from the shelf. Web servers are excellent at sending HTML, CSS, JavaScript, or image files without modification. They are lightweight and extremely fast.  &lt;/p&gt;

&lt;p&gt;An &lt;strong&gt;application server&lt;/strong&gt;, on the other hand, is designed to run your business logic. It is more like a chef in a restaurant: you give an order (the request), and the chef prepares the dish fresh based on ingredients (the data in your database). Application servers execute code, connect to databases, and build dynamic responses before handing them back to the client.  &lt;/p&gt;




&lt;h3&gt;
  
  
  A Practical Example
&lt;/h3&gt;

&lt;p&gt;Imagine an &lt;strong&gt;online bookstore&lt;/strong&gt;:  &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;When a customer visits the homepage, the banner image, stylesheet, and JavaScript files are all &lt;strong&gt;static content&lt;/strong&gt;. These are best served directly by a &lt;strong&gt;web server&lt;/strong&gt; like Nginx. The server simply grabs the files from disk and sends them to the browser.  &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;When the same customer searches for “science fiction,” things change. The request must go deeper: the application needs to query a database for matching titles, calculate availability, and maybe even personalize results based on past purchases. This is handled by the &lt;strong&gt;application server&lt;/strong&gt;. In a Python-based system, this might be &lt;strong&gt;Gunicorn&lt;/strong&gt;; in a Java system, it could be &lt;strong&gt;Tomcat&lt;/strong&gt;.  &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In a production setup, both usually work together. The web server sits in front, handling static files and passing dynamic requests to the application server. This division of labor keeps the system efficient: the librarian handles quick lookups, while the chef focuses on preparing custom orders.  &lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  The Role of Web Frameworks
&lt;/h2&gt;

&lt;p&gt;Developers rarely write web applications from scratch. Instead, they rely on &lt;strong&gt;web frameworks&lt;/strong&gt;, which provide pre-built tools and libraries to handle common tasks like routing, authentication, and rendering templates.  &lt;/p&gt;

&lt;p&gt;Some frameworks cover everything from the front-end to the back-end, and are known as &lt;strong&gt;full-stack frameworks&lt;/strong&gt;. Django in Python or Ruby on Rails in Ruby are prime examples. They allow you to build an entire application quickly by providing batteries-included functionality.  &lt;/p&gt;

&lt;p&gt;Other frameworks are deliberately small and lightweight, focusing only on the essentials. These are called &lt;strong&gt;microframeworks&lt;/strong&gt;, and Flask in Python or Express.js in Node.js are widely used examples. They are ideal when you want maximum flexibility or when building smaller services such as APIs.  &lt;/p&gt;

&lt;p&gt;On the client side, &lt;strong&gt;frontend frameworks&lt;/strong&gt; like React, Angular, and Vue.js help structure the user interface. They manage the state of your application, handle user interactions, and make single-page applications possible. The choice between these frameworks depends on the complexity of your project, your performance needs, and your team’s expertise.  &lt;/p&gt;




&lt;h2&gt;
  
  
  Performance Considerations
&lt;/h2&gt;

&lt;p&gt;When it comes to performance, the distinction between web servers and application servers becomes even more important. A web server serving static files is extremely fast because it simply streams files to the client. An application server, however, consumes far more resources because it must run code and often query databases.  &lt;/p&gt;

&lt;p&gt;This is why modern architectures often use a &lt;strong&gt;reverse proxy setup&lt;/strong&gt;, where a web server sits in front, handling static traffic and only forwarding dynamic requests to the application server. This keeps the system efficient and scalable, preventing the heavier application layer from becoming a bottleneck.  &lt;/p&gt;




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

&lt;p&gt;Understanding the difference between web servers and application servers is more than just a technical curiosity. It is the foundation of how modern websites and applications are built. The web server is the quick, reliable librarian that retrieves pre-written files, while the application server is the chef that prepares fresh, dynamic responses. Together, they create the seamless experience we often take for granted when browsing the internet.  &lt;/p&gt;

&lt;p&gt;By grasping these fundamentals — and seeing them in action through examples like an online bookstore — you gain the clarity needed to design, troubleshoot, and scale real-world applications.  &lt;/p&gt;

</description>
      <category>webdev</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
