<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[NetWork Things]]></title><description><![CDATA[NetWork Things]]></description><link>https://tcp-vs-udp123.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Tue, 24 Nov 2026 11:52:33 GMT</lastBuildDate><atom:link href="https://tcp-vs-udp123.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Hunting Through Linux: What the Filesystem Reveals About How the OS Really Works]]></title><description><![CDATA[This blog explores how a Linux system reveals its inner workings through its filesystem, focusing on configuration under /etc, virtual process data in…]]></description><link>https://tcp-vs-udp123.hashnode.dev/hunting-through-linux-what-the-filesystem-reveals-about-how-the-os-really-works</link><guid isPermaLink="true">https://tcp-vs-udp123.hashnode.dev/hunting-through-linux-what-the-filesystem-reveals-about-how-the-os-really-works</guid><category><![CDATA[Linux]]></category><category><![CDATA[ChaiCode]]></category><category><![CDATA[Chaiaurcode]]></category><dc:creator><![CDATA[Ashutosh Panda]]></dc:creator><pubDate>Wed, 22 Apr 2026 06:34:12 GMT</pubDate><content:encoded><![CDATA[<h2>Overview</h2>
<p>This blog explores how a Linux system reveals its inner workings through its filesystem, focusing on configuration under <code>/etc</code>, virtual process data in <code>/proc</code>, logs in <code>/var/log</code>, device nodes in <code>/dev</code>, authentication files, networking and DNS configuration, and service management via systemd unit files and <code>/etc/fstab</code>. Rather than listing commands, it highlights concrete files and directories, explains the problems they solve, and shares the insights they give into system behavior and security.</p>
<h2>1. <code>/etc</code>: The Brain of System Configuration</h2>
<p>On a running Linux system, <code>/etc</code> quickly stands out as the place where almost every system-wide decision is encoded as plain text. Historically a catch‑all for “miscellaneous” files, it has evolved into the central repository for configuration that controls networking, user accounts, services, authentication, and more.</p>
<p>Two key insights come from exploring <code>/etc</code>:</p>
<ul>
<li><p>Almost everything important is configured declaratively.</p>
</li>
<li><p>Many powerful changes boil down to editing a small, human‑readable file.</p>
</li>
</ul>
<p>For example:</p>
<ul>
<li><p><code>/etc/hostname</code> defines the machine’s network name that appears in prompts and network tools.</p>
</li>
<li><p><code>/etc/fstab</code> (covered later) defines how storage is mounted.</p>
</li>
<li><p>Directories like <code>/etc/ssh</code>, <code>/etc/apache2</code>, and <code>/etc/systemd</code> hold service‑specific configuration that system daemons read at startup.</p>
</li>
<li><p>This structure matters because it turns the system into something you can reason about and reproduce: configuration can be version‑controlled, audited, and copied to another machine to recreate behavior. It also makes misconfigurations easy to introduce, which is why root permissions are typically required to modify most files under <code>/etc</code>.</p>
</li>
</ul>
<h2>2. <code>/etc/passwd</code> and <code>/etc/shadow</code>: How User Accounts Really Work</h2>
<p>User management on Linux is built on two simple text files: <code>/etc/passwd</code> and <code>/etc/shadow</code>. Every login, <code>sudo</code> attempt, or <code>su</code> switch ultimately consults these files to map a username to a user ID and verify credentials.</p>
<ul>
<li><p><code>/etc/passwd</code> is the primary user account database: each line stores username, numeric user ID (UID), group ID, home directory, and default shell.</p>
</li>
<li><p>Historically it also stored password hashes, but that was insecure because the file must be world‑readable so tools can map UIDs to names.</p>
</li>
</ul>
<p>To solve this, Linux moved password hashes to <code>/etc/shadow</code>:</p>
<ul>
<li><p><code>/etc/shadow</code> stores encrypted password hashes plus password aging and expiry metadata.</p>
</li>
<li><p>It is readable only by root or privileged authentication services (typical permissions 640 or 600), which prevents normal users from grabbing password hashes and running offline attacks.</p>
</li>
</ul>
<p>The interesting insight here is how much security depends on the split between these files. The system deliberately keeps identity information public but protects secrets by isolating them in a more restricted file, showing a classic principle: minimize who can see sensitive data while keeping the rest of the system usable.</p>
<h2>3. <code>/etc/resolv.conf</code> and DNS Resolution</h2>
<p>When a process calls <code>getaddrinfo</code> to resolve <code>example.com</code>, the path it takes is surprisingly transparent if you look at <code>/etc</code>. The resolver first consults <code>/etc/nsswitch.conf</code> to decide which mechanisms (files, DNS, LDAP, etc.) to use; when <code>dns</code> is involved, it reads <code>/etc/resolv.conf</code> for details.</p>
<p><code>/etc/resolv.conf</code> configures the DNS resolver for the whole system:</p>
<ul>
<li><p><code>nameserver</code> lines list up to three DNS servers, in the order they will be tried.</p>
</li>
<li><p><code>search</code> or <code>domain</code> lines control how short hostnames are expanded into fully qualified domain names.</p>
</li>
<li><p><code>options</code> like <code>timeout</code>, <code>attempts</code>, <code>rotate</code>, and <code>ndots</code> fine‑tune behavior such as how long to wait per server, how many retries, and whether to round‑robin across servers.</p>
</li>
</ul>
<p>The key insight from exploring this file is how much of “the internet is slow” or “DNS is flaky” comes down to a few lines of text. Tweaks to the <code>nameserver</code> list or options like <code>timeout</code> and <code>attempts</code> can radically change perceived reliability and latency for every networked application on the system.</p>
<h2>4. Routing Tables via <code>/proc/net/route</code></h2>
<p>Routing decisions—where packets go when they leave the machine—are also visible in the filesystem. While tools like <code>ip route show</code> and <code>route -n</code> are familiar, they both read from the same source: <code>/proc/net/route</code>.</p>
<p><code>/proc/net/route</code> is a text representation of the kernel’s IPv4 routing table, with columns for destination, gateway, netmask, flags, metric, and interface. It encodes routing entries in hexadecimal, which user tools then translate into dotted‑decimal form.</p>
<p>From this file you can infer:</p>
<ul>
<li><p>The default gateway (destination <code>00000000</code>) that handles all traffic not matching a more specific route.</p>
</li>
<li><p>Which interface (e.g., <code>eth0</code>, <code>wlan0</code>) is used for a given subnet.</p>
</li>
<li><p>Route metrics, which define priorities when multiple routes match a destination.</p>
</li>
</ul>
<p>The interesting insight here is that routing is not some opaque kernel magic: it is fully visible via a pseudo‑file that any privileged user can parse. Tools like <code>ip</code>, <code>netstat</code>, and <code>route</code> are essentially convenience layers on top of this shared underlying representation.</p>
<h2>5. <code>/proc</code>: Processes and the Kernel as a Virtual Filesystem</h2>
<p>The <code>/proc</code> directory looks like a huge, strange tree of numbers and cryptic filenames, but it is actually one of the clearest windows into the kernel and running processes. It is a pseudo‑filesystem generated on the fly at runtime rather than stored on disk.</p>
<p>Key patterns show up quickly:</p>
<ul>
<li><p>Directories named by PID (<code>/proc/1</code>, <code>/proc/1234</code>, etc.) expose details about each process: command line (<code>cmdline</code>), memory maps (<code>maps</code>), open file descriptors (<code>fd/</code>), environment variables (<code>environ</code>), scheduling info (<code>sched</code>), and more.</p>
</li>
<li><p>Special entries like <code>/proc/self</code> and <code>/proc/thread-self</code> are symbolic links that resolve to the calling process or thread’s own directory, allowing code to introspect itself without knowing its PID.</p>
</li>
<li><p>Other <code>/proc</code> files provide system‑wide information, such as <code>/proc/cpuinfo</code>, <code>/proc/meminfo</code>, <code>/proc/uptime</code>, and <code>/proc/sys</code> for tunable kernel parameters.</p>
</li>
</ul>
<p>One particularly interesting security feature is the <code>hidepid</code> mount option for <code>/proc</code>, which controls who can see other users’ process details. Mounting <code>/proc</code> with <code>hidepid=1</code> or <code>hidepid=2</code> hides sensitive information like other users’ command lines and statuses, making reconnaissance attacks significantly harder.</p>
<p>The big insight from exploring <code>/proc</code> is that Linux exposes internal kernel state in a structured, filesystem‑like way. Instead of system calls for every query, many tools simply read these virtual files, which makes debugging and observability much more approachable.</p>
<h2>6. <code>/var/log</code>: The System’s Memory</h2>
<p>If <code>/proc</code> is the system’s live brain, <code>/var/log</code> is its long‑term memory. This directory holds the bulk of system, authentication, kernel, and application logs in plain text files.</p>
<p>Common logs include:</p>
<ul>
<li><p><code>/var/log/syslog</code> or <code>/var/log/messages</code>: general system messages, including startup events and daemon logs (distribution‑dependent)</p>
</li>
<li><p><code>/var/log/auth.log</code> or <code>/var/log/secure</code>: authentication events such as login attempts, <code>sudo</code> usage, and SSH access.</p>
</li>
<li><p><code>/var/log/kern.log</code> and <code>/var/log/dmesg</code>: kernel messages and boot‑time hardware detection information.</p>
</li>
<li><p>Service‑specific logs, such as <code>/var/log/httpd/</code> for Apache HTTP server access and error logs.</p>
</li>
</ul>
<p>From a short exploration of <code>/var/log</code>, two insights emerge:</p>
<ul>
<li><p>Almost every “mysterious” problem leaves a trace here—failed services, permission errors, and hardware issues usually emit log lines.</p>
</li>
<li><p>Security monitoring fundamentally depends on these files; brute‑force login attempts, privilege escalations, or suspicious service behavior are visible if you know where to look.</p>
</li>
</ul>
<p>Because these logs can contain sensitive information (usernames, IP addresses, error messages), permissions and log rotation (<code>logrotate</code>) become critical for both privacy and disk usage.</p>
<h2>7. <code>/dev</code>: Devices as Files</h2>
<p>The <code>/dev</code> directory demonstrates one of Unix’s core ideas: “everything is a file.” It contains <em>device files</em> (also called device nodes) that provide user‑space access to hardware and pseudo‑devices.</p>
<p>Key characteristics of <code>/dev</code>:</p>
<ul>
<li><p>Files such as <code>/dev/sda</code>, <code>/dev/sda1</code>, <code>/dev/tty</code>, <code>/dev/null</code>, and <code>/dev/random</code> represent block or character devices.</p>
</li>
<li><p><code>ls -l /dev</code> shows that these entries have type <code>b</code> (block) or <code>c</code> (character) instead of a regular file size; instead they have <em>major</em> and <em>minor</em> numbers that identify which driver and which specific device to talk to.</p>
</li>
<li><p>Many subdirectories group devices by type or naming scheme, such as <code>/dev/disk/by-uuid</code> for disks referenced by filesystem UUID.</p>
</li>
</ul>
<p>The important insight is that user programs rarely talk to hardware directly. They open these special files and perform read/write or <code>ioctl</code> operations, while the kernel routes those calls to the appropriate driver based on the device’s major/minor numbers. This abstraction makes it possible to treat a sound card, a disk, and a pseudo‑terminal in a uniform, file‑oriented way.</p>
<h2>8. System Services in <code>/etc/systemd/system</code></h2>
<p>On a modern distribution that uses systemd, service management is configured through unit files, many of which live under <code>/etc/systemd/system</code>. These text files describe how services are started, stopped, and ordered relative to each other.</p>
<p>Key points about systemd unit files:</p>
<ul>
<li><p>A unit file ending in <code>.service</code> defines a long‑running daemon, with sections like <code>[Unit]</code> (metadata and dependencies), <code>[Service]</code> (how to start/stop the process), and <code>[Install]</code> (how it hooks into boot targets).</p>
</li>
<li><p>Systemd searches for unit files in multiple locations, but <code>/etc/systemd/system</code> is reserved for administrator‑created or customized units and overrides, which take precedence over distribution defaults from <code>/usr/lib/systemd/system</code> or <code>/lib/systemd/system</code>.</p>
</li>
<li><p>Additional configuration can be supplied via drop‑in directories like <code>sshd.service.d/override.conf</code>, allowing targeted adjustments without editing vendor‑supplied unit files.</p>
</li>
</ul>
<p>Exploring this directory shows how boot and service orchestration are encoded as data. You can see which services start at boot, how they depend on network or filesystem targets, and how enabling or disabling a service with <code>systemctl enable/disable</code> corresponds to symlinks and unit metadata on disk.</p>
<h2>9. <code>/etc/fstab</code>: Declarative Storage and Mounting</h2>
<p>While <code>/dev</code> shows the raw devices, <code>/etc/fstab</code> explains how they should be stitched into the filesystem tree. This file defines which partitions or remote filesystems are mounted where, with which options, and when.</p>
<p>Each line in <code>/etc/fstab</code> has six fields: device, mountpoint, filesystem type, mount options, dump flag, and fsck order. For example, distributions commonly list entries like:</p>
<ul>
<li><p>A root filesystem (e.g., <code>UUID=... / ext4 defaults 0 1</code>).</p>
</li>
<li><p>A separate <code>/home</code> partition.</p>
</li>
<li><p>A swap partition with no mount point.</p>
</li>
<li><p>A boot partition or EFI system partition mounted at <code>/boot</code>.</p>
</li>
</ul>
<p>Modern systems often use UUIDs or labels instead of raw <code>/dev/sda1</code> style names to avoid problems when device ordering changes. Mount options such as <code>noexec</code>, <code>nodev</code>, <code>nosuid</code>, or user‑friendly flags for network shares and exFAT drives play a surprisingly important role in security and usability.</p>
<p>The main insight from studying <code>/etc/fstab</code> is that storage layout is both declarative and reproducible. A server’s disk and network share configuration can be captured entirely in this file, making it easy to rebuild or audit how data is organized and what protections are applied at the filesystem level.</p>
<h2>10. Why These Files Matter for Understanding Linux</h2>
<p>Walking through these directories—<code>/etc</code>, <code>/proc</code>, <code>/var/log</code>, <code>/dev</code>, <code>/etc/systemd/system</code>, and <code>/etc/fstab</code>—shows that Linux is less of a black box and more of a set of transparent contracts expressed as files.</p>
<p>Configuration, state, and behavior are exposed in ways that can be inspected, scripted, and version‑controlled.</p>
<p>Some overarching lessons from this filesystem exploration are:</p>
<ul>
<li><p><strong>Text files as APIs</strong>: Many “APIs” in Linux are just well‑defined text files that tools read and write—<code>/proc</code> for live kernel state, <code>/etc/*</code> for configuration, and <code>/var/log/*</code> for historical events.</p>
</li>
<li><p><strong>Security via structure and permissions</strong>: Splitting <code>/etc/passwd</code> and <code>/etc/shadow</code>, restricting <code>/proc</code> visibility with <code>hidepid</code>, and carefully choosing <code>/etc/fstab</code> mount options are all examples of how filesystem layout and permissions enforce security policies.</p>
</li>
<li><p><strong>Declarative system behavior</strong>: From DNS (<code>/etc/resolv.conf</code>) and routing (<code>/proc/net/route</code>) to services (<code>/etc/systemd/system</code>) and storage (<code>/etc/fstab</code>), much of Linux behavior is defined declaratively and interpreted by daemons and the kernel.</p>
</li>
</ul>
<p>For anyone learning Linux, treating the filesystem as a map of how the OS actually works—rather than just a place to store files—turns routine administration into a genuine systems‑level investigation.</p>
]]></content:encoded></item><item><title><![CDATA[TCP vs UDP: When to Use What, and How TCP Relates to HTTP]]></title><description><![CDATA[TCP :- TCP is connection oriented and reliable. Connection oriented because the lower levels on the network stack maintain the notion of two computers are…]]></description><link>https://tcp-vs-udp123.hashnode.dev/tcp-vs-udp-when-to-use-what-and-how-tcp-relates-to-http</link><guid isPermaLink="true">https://tcp-vs-udp123.hashnode.dev/tcp-vs-udp-when-to-use-what-and-how-tcp-relates-to-http</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[Chaiaurcode]]></category><category><![CDATA[ChaiCohort]]></category><dc:creator><![CDATA[Ashutosh Panda]]></dc:creator><pubDate>Sun, 25 Jan 2026 19:49:56 GMT</pubDate><content:encoded><![CDATA[<h2 id="heading-what-are-tcp-and-udp-at-a-very-high-level">What are TCP and UDP (at a very high level)</h2>
<p><strong>TCP :-</strong> TCP is connection oriented and reliable. Connection oriented because the lower levels on the network stack maintain the notion of two computers are communicating and can tell you if the connection is lost or formally closed. Reliable because the sequence of data is ordered, any data recieved out of order is ordered before being passed to the application, and any missing packets are communicated so they can be sent again. There's also consistency checking to make sure the packet isn't corrupt, otherwise, it's sent again. The model is of a stream.</p>
<p><strong>UDP :-</strong> UDP is unreliable and connectionless. There is no notion of formally connecting or disconnecting systems that are communicating. The data model is of packets. There is no notion of order, and packets can arrive in any order. There's no way of knowing if packets didn't make it. If a packet is corrupt, it's thrown away, and not requested for a resend. There's no way of knowing if your data is reaching it's destination, or if the connection is broken.</p>
<p>Streams are used for some kinds of media, and when reliability is needed. Packets are used if loss is tolerable. Sometimes, and this kind of escapes me as a professional developer, a bastardized version of TCP is built on top of UDP.</p>
<h2 id="heading-when-to-use-tcp">When to use TCP ?</h2>
<p>TCP is when both people are talking to each other and can ask questions for clarification to make sure all the information is correct and accurate. etc…….</p>
<h2 id="heading-when-to-use-udp">When to use UDP ?</h2>
<p>UDP is when one persons sends all the information and doesn't care if the other one is listening or even in what order they get the information. etc…….</p>
<h2 id="heading-like-where-we-are-using-these-things">Like where we are using these things ?</h2>
<p>TCP : E-mail. If even one packet of data doesn't make, the entire E-mail could or would be completely different or unreadable. etc…….</p>
<p>UDP : Games or streaming video. For video, if a couple of frames don't reach their destination once in a while, you probably won't even notice. etc…….</p>
<h2 id="heading-what-is-http-and-where-it-fits">What is HTTP and where it fits</h2>
<p>HTTP is the language the letters are written in. For instance, I might choose to write letters in English, and just like how English defines a grammar, HTTP defines a grammar for the communication. Someone might write a letter in Spanish (FTP / File Transfer Protocol) using the same envelopes and that'll be fine as well. The important bit if all kinds of letters (English, Spanish) are using same envelopes.</p>
<h2 id="heading-relationship-between-tcp-and-http">Relationship between TCP and HTTP</h2>
<p>TCP/IP transmits small packets of data between two computers. It’s a way to transmit bits blindly but with confirmation that the recipient got them, and a way to resend them if it didn’t.</p>
<p>TCP (Transmission Control Protocol) is a type of packet that can be sent within the payload of IP packets, which defines more headers that can help with ensuring packets reach the destination without any data loss (via <strong>acknowledgements</strong>) or corruption (via <strong>checksums</strong>), and in the correct order (via <strong>sequence numbers</strong>), and processed by the correct software (using <strong>ports</strong>).</p>
<p>TCP/IP is the protocol that carries the HTTP protocol data. HTTP is the protocol for your web data, and REST API is a means of interacting with a web application. The data used when you interact with the REST API of a web application is transferred via HTTP/S, and HTTP/S is transferred using TCP/IP.</p>
<hr />
<p>HTTP is a layer on top of TCP/IP that transmits typed chunks of data. It gets transmitted in TCP packets, and HTTP communicates what type of data it is and how to assemble the packets into the larger type.</p>
<p>HTTP (Hypertext Transfer Protocol) is one of the main protocols that forms the foundation of the World Wide Web. It defines how <strong>client</strong> software (eg. web browser) can send text-based commands (<strong>requests</strong>) to a <strong>web server</strong> and receive a reply (<strong>response</strong>).</p>
<p>HTTP is layer 7 (Application) of the OSI model, TCP is layer 4 (Transport) of the OSI model. If you want to just apply the TCP/IP model, HTTP is the application layer of the TCP/IP model.</p>
]]></content:encoded></item></channel></rss>