<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Coder Legion - Recent posts tagged tech blog</title>
<link>https://coderlegion.com/tag/tech+blog</link>
<description>Powered by Question2Answer</description>
<item>
<title>Linux Fundamentals For DevOps: Linux core mechanism</title>
<link>https://coderlegion.com/16002/linux-fundamentals-for-devops-linux-core-mechanism</link>
<description>&lt;p&gt;Knowing where files live is only half the battle. To be an effective DevOps engineer, you need to know how Linux actually executes programs, manages their lifecycles, and secures them.&lt;br&gt;
The crucial concepts you need to troubleshoot effectively.&lt;/p&gt;
&lt;h3 id=&quot;the-path-variable&quot;&gt;The &lt;code&gt;$PATH&lt;/code&gt; Variable&lt;/h3&gt;
&lt;p&gt;Linux does not search your entire hard drive when you type a command. It only checks a specific, prioritized list of folders. This list is saved in an environment variable called &lt;code&gt;$PATH&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;You download a new binary tool (like &lt;code&gt;kubectl&lt;/code&gt; or &lt;code&gt;terraform&lt;/code&gt;). You type its name in the terminal, but Linux replies with the dreaded &lt;code&gt;command not found&lt;/code&gt;. To fix this, you must either move the binary into a folder that is already in your &lt;code&gt;$PATH&lt;/code&gt;, or add your custom folder to the &lt;code&gt;$PATH&lt;/code&gt;.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-shell&quot;&gt;# Command: View the list of directories Linux currently checks for commands

echo $PATH

# Output Proof (Directories are separated by colons):
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

# Command: Add your custom scripts folder to the PATH for the current session

export PATH=&quot;/home/saeed/custom-scripts:$PATH&quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;how-binaries-work-shared-libraries-&quot;&gt;How Binaries Work (Shared Libraries)&lt;/h3&gt;
&lt;p&gt;When you run a command like &lt;code&gt;nginx&lt;/code&gt; or &lt;code&gt;python&lt;/code&gt;, you are executing a binary file. In Linux, executables are typically formatted as ELF (Executable and Linkable Format) files. However, most binaries are not standalone; they rely on external pieces of code called shared libraries (&lt;code&gt;.so&lt;/code&gt; files, similar to &lt;code&gt;.dll&lt;/code&gt; files in Windows).&lt;/p&gt;
&lt;p&gt;You compile a Go application or migrate a tool into a minimal Docker container (like Alpine Linux). When you run it, it crashes silently or throws a confusing &lt;code&gt;no such file or directory&lt;/code&gt; error—even though you can see the binary sitting right there. Usually, the binary isn't missing; &lt;strong&gt;its required &lt;em&gt;libraries&lt;/em&gt; are missing.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;You can use the &lt;code&gt;ldd&lt;/code&gt; command to print the shared libraries required by any program.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-shell&quot;&gt;# Command: Verify exactly which shared libraries Nginx needs to run
ldd /usr/sbin/nginx

# Output Proof:
        linux-vdso.so.1 (0x00007ffe3b1f4000)
        libcrypt.so.1 =&amp;gt; /lib/x86_64-linux-gnu/libcrypt.so.1 (0x00007f3a8b411000)
        libpcre.so.3 =&amp;gt; /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f3a8b39c000)
        libssl.so.3 =&amp;gt; /lib/x86_64-linux-gnu/libssl.so.3 (0x00007f3a8b2f6000)
        libc.so.6 =&amp;gt; /lib/x86_64-linux-gnu/libc.so.6 (0x00007f3a8b0cd000)
&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;file-permission&quot;&gt;File Permission&lt;/h3&gt;
&lt;p&gt;Linux strict permissions dictate exactly who can &lt;strong&gt;R&lt;/strong&gt;ead, &lt;strong&gt;W&lt;/strong&gt;rite, or e&lt;strong&gt;X&lt;/strong&gt;ecute a file. This is often represented by numbers (like 777 or 644).&lt;/p&gt;
&lt;p&gt;You are trying to connect to a cloud server via SSH using a private key (&lt;code&gt;.pem&lt;/code&gt; file), but the connection is instantly rejected. If you set a &lt;code&gt;.pem&lt;/code&gt; file to &lt;code&gt;777&lt;/code&gt; (meaning everyone on the system can &lt;strong&gt;read&lt;/strong&gt;, &lt;strong&gt;write&lt;/strong&gt;, and &lt;strong&gt;execute&lt;/strong&gt; it), SSH will intentionally reject it for being too exposed. Private keys must be set to &lt;code&gt;400&lt;/code&gt;—meaning absolutely no one except the owner is allowed to read it.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-shell&quot;&gt;# Command: Attempting to SSH with a bad permission key
ssh -i my-key.pem ubuntu@10.0.0.5

# Output Proof:
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0777 for 'my-key.pem' are too open.

# Command: Secure the key so only the owner can read it (4), and no one can write (0) or execute (0)

chmod 400 my-key.pem
&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;processes-and-signals&quot;&gt;Processes and Signals&lt;/h3&gt;
&lt;p&gt;Every running program is a process assigned a unique Process ID (PID). The operating system communicates with and controls these processes using &quot;Signals.&quot;&lt;/p&gt;
&lt;p&gt;An application is hogging 100% of the CPU and needs to be stopped, or Kubernetes is trying to scale down a pod without dropping active user connections. You can send a &lt;code&gt;SIGTERM&lt;/code&gt; (Signal 15), which politely asks the program to save its data and exit cleanly. Alternatively, a &lt;code&gt;SIGKILL&lt;/code&gt; (Signal 9) forcefully terminates it at the hardware level, bypassing cleanup and potentially causing data corruption.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-shell&quot;&gt;# Command: Find the Process ID of an application
pgrep -la nginx

# Output Proof:
1234 nginx: master process
1235 nginx: worker process

# Command: Politely ask the master process to shut down and clean up
kill -15 1234
&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;file-descriptors&quot;&gt;File Descriptors&lt;/h3&gt;
&lt;p&gt;Remember concept , &lt;strong&gt;&quot;Everything is a File&quot;&lt;/strong&gt;? That rule has a dark side.&lt;/p&gt;
&lt;p&gt;Because Linux treats &lt;strong&gt;&lt;em&gt;network connections&lt;/em&gt;&lt;/strong&gt; as files, every time a user connects to your web server, the operating system opens a &quot;File Descriptor&quot; to track that connection. To protect itself from crashing, the Linux kernel sets strict limits on how many file descriptors a single process can open at once.&lt;/p&gt;
&lt;p&gt;Your Nginx web server or Node.js application is suddenly dropping user connections during a high-traffic spike. You check the CPU and RAM, and both are perfectly fine. You check the Nginx error logs and see the dreaded &lt;code&gt;worker_connections are not enough&lt;/code&gt; or &lt;code&gt;Too many open files&lt;/code&gt; error. The operating system has forcibly stopped your app from accepting new traffic.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-shell&quot;&gt;# Command: Show the maximum number of open file descriptors allowed for this user
ulimit -n

# Output Proof:
1024

# Command: Check how many file descriptors the entire system is currently using
cat /proc/sys/fs/file-nr

# Output Proof:
1205   0   9223372036854775807
&lt;/code&gt;&lt;/pre&gt;
&lt;h4 id=&quot;blog-summary&quot;&gt;Blog Summary&lt;/h4&gt;
&lt;p&gt;Understanding Linux goes beyond knowing where files live; it’s about understanding how the operating system executes code, secures data, and manages its own limits. This guide breaks down the invisible mechanics of Linux that every DevOps engineer must master to troubleshoot effectively.&lt;/p&gt;
&lt;p&gt;You'll learn why binaries silently fail due to missing shared libraries, how to quickly fix &quot;command not found&quot; errors using the &lt;code&gt;$PATH&lt;/code&gt; variable, and the strict permission rules required to secure SSH keys. We also cover how to safely manage and terminate running processes using signals, and finally, uncover the hidden trap of File Descriptors—explaining why servers suddenly drop connections with &quot;Too many open files&quot; errors and how to raise those limits.&lt;/p&gt;
</description>
<category>Articles</category>
<guid isPermaLink="true">https://coderlegion.com/16002/linux-fundamentals-for-devops-linux-core-mechanism</guid>
<pubDate>Mon, 27 Apr 2026 16:45:13 +0000</pubDate>
</item>
</channel>
</rss>