<?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: Farhad Rahimi Klie</title>
    <description>The latest articles on DEV Community by Farhad Rahimi Klie (@farhadrahimiklie).</description>
    <link>https://dev.to/farhadrahimiklie</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3424859%2Fc13c2c54-3160-4d41-9cdf-9ca26cf28fa8.jpg</url>
      <title>DEV Community: Farhad Rahimi Klie</title>
      <link>https://dev.to/farhadrahimiklie</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/farhadrahimiklie"/>
    <language>en</language>
    <item>
      <title>Critical Thinking in Programming: The Skill AI Can't Replace</title>
      <dc:creator>Farhad Rahimi Klie</dc:creator>
      <pubDate>Fri, 02 Oct 2026 03:59:39 +0000</pubDate>
      <link>https://dev.to/farhadrahimiklie/critical-thinking-in-programming-the-skill-ai-cant-replace-7gm</link>
      <guid>https://dev.to/farhadrahimiklie/critical-thinking-in-programming-the-skill-ai-cant-replace-7gm</guid>
      <description>&lt;p&gt;AI can write code.&lt;/p&gt;

&lt;p&gt;AI can explain code.&lt;/p&gt;

&lt;p&gt;AI can find bugs.&lt;/p&gt;

&lt;p&gt;AI can even build entire applications from a simple description.&lt;/p&gt;

&lt;p&gt;So a natural question for programmers is:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;If AI can do so much of the coding, what skill should a programmer develop that AI cannot simply replace?&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;One of the most important answers is &lt;strong&gt;critical thinking&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Programming has never been only about typing code. The difficult part is usually deciding &lt;strong&gt;what should be built, why it should be built, what assumptions are being made, and whether the result is actually correct&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;AI can generate an implementation.&lt;/p&gt;

&lt;p&gt;You still need to decide whether that implementation makes sense.&lt;/p&gt;




&lt;h2&gt;
  
  
  What Is Critical Thinking?
&lt;/h2&gt;

&lt;p&gt;Critical thinking is the ability to examine information carefully, question assumptions, evaluate evidence, identify problems, and reach a reasoned conclusion.&lt;/p&gt;

&lt;p&gt;In programming, this means asking questions such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What exactly is the problem?&lt;/li&gt;
&lt;li&gt;What are the requirements?&lt;/li&gt;
&lt;li&gt;Are the requirements complete?&lt;/li&gt;
&lt;li&gt;What assumptions am I making?&lt;/li&gt;
&lt;li&gt;Is this solution actually correct?&lt;/li&gt;
&lt;li&gt;What happens in unusual cases?&lt;/li&gt;
&lt;li&gt;What could fail?&lt;/li&gt;
&lt;li&gt;Is there a simpler solution?&lt;/li&gt;
&lt;li&gt;What are the security implications?&lt;/li&gt;
&lt;li&gt;What are the performance implications?&lt;/li&gt;
&lt;li&gt;How do I know this code works?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A programmer who can write 10,000 lines of code but cannot answer these questions can still build the wrong software.&lt;/p&gt;




&lt;h2&gt;
  
  
  Programming Is Not Just Writing Code
&lt;/h2&gt;

&lt;p&gt;Consider a simple request:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Create a function that deletes a user."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;An AI can quickly generate something like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;delete_user&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;user_id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;database_delete_user&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;user_id&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The code may compile.&lt;/p&gt;

&lt;p&gt;But critical thinking begins &lt;strong&gt;before&lt;/strong&gt; writing the function.&lt;/p&gt;

&lt;p&gt;You should ask:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Should the user really be deleted?&lt;/li&gt;
&lt;li&gt;What if the user doesn't exist?&lt;/li&gt;
&lt;li&gt;What happens to their files?&lt;/li&gt;
&lt;li&gt;What happens to their posts?&lt;/li&gt;
&lt;li&gt;What happens to their payments?&lt;/li&gt;
&lt;li&gt;Should deletion be permanent?&lt;/li&gt;
&lt;li&gt;Should administrators be allowed to delete users?&lt;/li&gt;
&lt;li&gt;Should the operation require confirmation?&lt;/li&gt;
&lt;li&gt;What happens if the database operation fails halfway through?&lt;/li&gt;
&lt;li&gt;Should the action be logged?&lt;/li&gt;
&lt;li&gt;Can another user trigger this operation?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The difficult problem wasn't writing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="n"&gt;database_delete_user&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;user_id&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The difficult problem was understanding what &lt;strong&gt;"delete a user" actually means&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;That's critical thinking.&lt;/p&gt;




&lt;h2&gt;
  
  
  AI Is Extremely Good at Generating Solutions
&lt;/h2&gt;

&lt;p&gt;Modern AI systems are remarkably useful for programming.&lt;/p&gt;

&lt;p&gt;You can ask AI to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;generate functions&lt;/li&gt;
&lt;li&gt;explain APIs&lt;/li&gt;
&lt;li&gt;convert code between languages&lt;/li&gt;
&lt;li&gt;write tests&lt;/li&gt;
&lt;li&gt;find potential bugs&lt;/li&gt;
&lt;li&gt;refactor code&lt;/li&gt;
&lt;li&gt;generate documentation&lt;/li&gt;
&lt;li&gt;explain compiler errors&lt;/li&gt;
&lt;li&gt;create project structures&lt;/li&gt;
&lt;li&gt;suggest algorithms&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This makes AI an extremely powerful programming assistant.&lt;/p&gt;

&lt;p&gt;But there is an important distinction:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Generating a solution is different from determining whether the solution is the right one.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;For example, imagine asking AI:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Create a filesystem that stores files in a disk image.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;AI can generate structures like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="k"&gt;struct&lt;/span&gt; &lt;span class="n"&gt;FileEntry&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kt"&gt;char&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;32&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;size&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;start_block&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It can generate allocation functions.&lt;/p&gt;

&lt;p&gt;It can generate bitmap code.&lt;/p&gt;

&lt;p&gt;It can generate file-reading and file-writing functions.&lt;/p&gt;

&lt;p&gt;But you still have to decide:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;How is free space represented?&lt;/li&gt;
&lt;li&gt;Can files grow?&lt;/li&gt;
&lt;li&gt;What happens when a file needs another block?&lt;/li&gt;
&lt;li&gt;How are directories represented?&lt;/li&gt;
&lt;li&gt;What happens when the disk becomes full?&lt;/li&gt;
&lt;li&gt;How is corruption detected?&lt;/li&gt;
&lt;li&gt;What happens if the program crashes during a write?&lt;/li&gt;
&lt;li&gt;How are blocks recovered?&lt;/li&gt;
&lt;li&gt;Can two files accidentally reference the same block?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The code is only part of the filesystem.&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;architecture and reasoning&lt;/strong&gt; are much more important.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Most Important Question: "Why?"
&lt;/h2&gt;

&lt;p&gt;A beginner often asks:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"How do I implement this?"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;An experienced programmer often asks:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;"Why should I implement it this way?"&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That difference is enormous.&lt;/p&gt;

&lt;p&gt;Suppose you need to store 1 million records.&lt;/p&gt;

&lt;p&gt;Someone suggests:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Use an array.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You might immediately implement it.&lt;/p&gt;

&lt;p&gt;But critical thinking asks:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Why an array?
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;How often will we search?
How often will we insert?
How often will we delete?
Do we need ordering?
How much memory do we have?
What is the expected dataset size?
What is the access pattern?
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Maybe an array is correct.&lt;/p&gt;

&lt;p&gt;Maybe a hash table is better.&lt;/p&gt;

&lt;p&gt;Maybe a tree is better.&lt;/p&gt;

&lt;p&gt;Maybe a database is appropriate.&lt;/p&gt;

&lt;p&gt;The programming language doesn't answer these questions.&lt;/p&gt;

&lt;p&gt;The algorithm doesn't answer them automatically.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;You have to reason about the problem.&lt;/strong&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Don't Trust Code Just Because It Compiles
&lt;/h2&gt;

&lt;p&gt;One of the most dangerous mistakes in programming is assuming:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;It compiles → It works.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's false.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;divide&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It compiles.&lt;/p&gt;

&lt;p&gt;But what happens when:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="n"&gt;divide&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Critical thinking means looking beyond the happy path.&lt;/p&gt;

&lt;p&gt;You should automatically start thinking about:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Normal input
Empty input
Zero
Negative values
Very large values
Very small values
Invalid input
Unexpected input
Memory limitations
Concurrency
Failure conditions
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This habit becomes extremely valuable when working with AI-generated code.&lt;/p&gt;




&lt;h2&gt;
  
  
  AI Can Be Confidently Wrong
&lt;/h2&gt;

&lt;p&gt;AI-generated code can look professional.&lt;/p&gt;

&lt;p&gt;It can have:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;beautiful formatting&lt;/li&gt;
&lt;li&gt;meaningful variable names&lt;/li&gt;
&lt;li&gt;comments&lt;/li&gt;
&lt;li&gt;error handling&lt;/li&gt;
&lt;li&gt;impressive architecture&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And still be wrong.&lt;/p&gt;

&lt;p&gt;This is why one of the most valuable programming skills in the AI era is:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;The ability to independently verify the output.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If AI gives you 200 lines of code, don't think:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"The AI wrote it, so it must be correct."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Think:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"What assumptions does this code make?"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Then test those assumptions.&lt;/p&gt;




&lt;h2&gt;
  
  
  Learn to Question Assumptions
&lt;/h2&gt;

&lt;p&gt;Assumptions are everywhere in software.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="kt"&gt;char&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;malloc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="n"&gt;strcpy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;input&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Someone might say:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"It allocates 100 bytes, so we're safe."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;But critical thinking asks:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;How long is input?
Can input contain more than 99 characters?
Is it null terminated?
What happens if allocation fails?
Who frees the memory?
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The code itself doesn't tell you all of these answers.&lt;/p&gt;

&lt;p&gt;You have to reason about the surrounding system.&lt;/p&gt;




&lt;h2&gt;
  
  
  Debugging Is Critical Thinking
&lt;/h2&gt;

&lt;p&gt;Many people think debugging means:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Find the line that is broken.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That's only part of debugging.&lt;/p&gt;

&lt;p&gt;Real debugging is closer to scientific investigation.&lt;/p&gt;

&lt;p&gt;You have:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Observation
    ↓
Hypothesis
    ↓
Experiment
    ↓
Result
    ↓
New hypothesis
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Suppose your program crashes.&lt;/p&gt;

&lt;p&gt;Don't randomly change code.&lt;/p&gt;

&lt;p&gt;Instead ask:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;What exactly happened?
Where did it happen?
Can I reproduce it?
What changed?
What does the debugger show?
What assumptions were violated?
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Program crashes
      ↓
Is it always reproducible?
      ↓
Yes
      ↓
Which operation occurs immediately before the crash?
      ↓
Memory access
      ↓
Is the pointer valid?
      ↓
Check pointer
      ↓
Pointer is NULL
      ↓
Where did NULL come from?
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's critical thinking.&lt;/p&gt;




&lt;h2&gt;
  
  
  Learn to Think in Invariants
&lt;/h2&gt;

&lt;p&gt;One of the strongest techniques in programming is reasoning with &lt;strong&gt;invariants&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;An invariant is something that should remain true throughout a system.&lt;/p&gt;

&lt;p&gt;For example, imagine a filesystem.&lt;/p&gt;

&lt;p&gt;You might define:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Every allocated block belongs to exactly one file.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now consider this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;File A → Block 10
File B → Block 10
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Your invariant has been violated.&lt;/p&gt;

&lt;p&gt;That immediately tells you something is wrong.&lt;/p&gt;

&lt;p&gt;Another filesystem invariant could be:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;If a file says it owns N blocks,
then exactly N valid block references must exist.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Thinking in invariants helps you reason about complex systems instead of merely reading individual lines of code.&lt;/p&gt;




&lt;h2&gt;
  
  
  Critical Thinking Helps You Design Better Systems
&lt;/h2&gt;

&lt;p&gt;Imagine you're building a small operating-system-like project.&lt;/p&gt;

&lt;p&gt;You need memory allocation.&lt;/p&gt;

&lt;p&gt;You could ask AI:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Write malloc."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;It may produce an implementation.&lt;/p&gt;

&lt;p&gt;But before implementation, you need to understand:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;What is a block?
How is free memory represented?
How are allocations tracked?
What happens when memory is fragmented?
How is memory returned?
What alignment is required?
What happens when allocation fails?
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The implementation comes after the model.&lt;/p&gt;

&lt;p&gt;A programmer who understands the model can evaluate AI-generated implementations.&lt;/p&gt;

&lt;p&gt;A programmer who doesn't understand the model may simply copy them.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Difference Between a Coder and an Engineer
&lt;/h2&gt;

&lt;p&gt;This doesn't mean writing code is unimportant.&lt;/p&gt;

&lt;p&gt;It means programming has multiple levels.&lt;/p&gt;

&lt;h3&gt;
  
  
  Level 1 — Syntax
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(...)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="p"&gt;...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You know how to write valid code.&lt;/p&gt;

&lt;h3&gt;
  
  
  Level 2 — Implementation
&lt;/h3&gt;

&lt;p&gt;You can build functions and programs.&lt;/p&gt;

&lt;h3&gt;
  
  
  Level 3 — Algorithms
&lt;/h3&gt;

&lt;p&gt;You understand:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;arrays&lt;/li&gt;
&lt;li&gt;linked lists&lt;/li&gt;
&lt;li&gt;hash tables&lt;/li&gt;
&lt;li&gt;trees&lt;/li&gt;
&lt;li&gt;graphs&lt;/li&gt;
&lt;li&gt;sorting&lt;/li&gt;
&lt;li&gt;searching&lt;/li&gt;
&lt;li&gt;memory allocation&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Level 4 — Design
&lt;/h3&gt;

&lt;p&gt;You can decide how components should interact.&lt;/p&gt;

&lt;h3&gt;
  
  
  Level 5 — Reasoning
&lt;/h3&gt;

&lt;p&gt;You can determine:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;What problem are we actually solving?
What constraints matter?
What assumptions are dangerous?
What could go wrong?
How can we prove or test correctness?
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;AI can help with all five levels.&lt;/p&gt;

&lt;p&gt;But the higher levels require increasingly strong judgment from the programmer.&lt;/p&gt;




&lt;h2&gt;
  
  
  Don't Become a "Prompt Programmer"
&lt;/h2&gt;

&lt;p&gt;A new type of programming workflow is emerging:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Human:
"Build this."

AI:
"Here is the code."

Human:
"Fix this."

AI:
"Here is the fix."

Human:
"Add authentication."

AI:
"Done."

Human:
"Deploy it."

AI:
"Done."
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This can be productive.&lt;/p&gt;

&lt;p&gt;But there is a danger.&lt;/p&gt;

&lt;p&gt;You can become dependent on generated code without understanding the system you're building.&lt;/p&gt;

&lt;p&gt;Then when something unexpected happens, you don't know how to reason about it.&lt;/p&gt;

&lt;p&gt;A better workflow is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Understand
    ↓
Design
    ↓
Ask AI for assistance
    ↓
Inspect
    ↓
Test
    ↓
Challenge assumptions
    ↓
Modify
    ↓
Verify
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;AI becomes your tool.&lt;/p&gt;

&lt;p&gt;You remain the engineer.&lt;/p&gt;




&lt;h2&gt;
  
  
  Ask AI Better Questions
&lt;/h2&gt;

&lt;p&gt;Instead of only asking:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Write this function."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Try asking:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"What are the possible failure cases?"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Or:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"What assumptions does this implementation make?"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Or:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Give me three possible architectures and explain the trade-offs."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Or:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"What security problems could exist here?"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Or:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"What edge cases should I test?"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Or:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Find situations where this algorithm produces incorrect results."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;These questions force you to think about the problem rather than simply accepting generated code.&lt;/p&gt;




&lt;h2&gt;
  
  
  Build Things Without AI Sometimes
&lt;/h2&gt;

&lt;p&gt;If you want strong programming fundamentals, occasionally build something yourself.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Text editor
Calculator
Shell
Memory allocator
HTTP server
Database
Filesystem
Compiler
Interpreter
Version-control system
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Start small.&lt;/p&gt;

&lt;p&gt;The goal isn't to compete with commercial software.&lt;/p&gt;

&lt;p&gt;The goal is to experience the underlying problems.&lt;/p&gt;

&lt;p&gt;For example, building a tiny filesystem teaches you about:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Blocks
Metadata
Directories
Allocation
Bitmaps
File offsets
Persistence
Corruption
Data structures
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Those experiences create mental models that are difficult to obtain by simply asking an AI to generate the project.&lt;/p&gt;




&lt;h2&gt;
  
  
  Read Code You Didn't Write
&lt;/h2&gt;

&lt;p&gt;Another powerful exercise is reading unfamiliar code.&lt;/p&gt;

&lt;p&gt;Pick a project and ask:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;What does this function do?

What assumptions does it make?

What data structure is being used?

Why was this algorithm chosen?

What happens if this input is invalid?

What happens if memory allocation fails?

What happens if the disk is full?

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

&lt;/div&gt;



&lt;p&gt;Before running the program, try to predict its behavior.&lt;/p&gt;

&lt;p&gt;Then run it.&lt;/p&gt;

&lt;p&gt;Compare your prediction with reality.&lt;/p&gt;

&lt;p&gt;This trains your reasoning ability.&lt;/p&gt;




&lt;h2&gt;
  
  
  Learn the Fundamentals
&lt;/h2&gt;

&lt;p&gt;Critical thinking becomes much stronger when you understand the foundations.&lt;/p&gt;

&lt;p&gt;For a programmer, that includes topics such as:&lt;/p&gt;

&lt;h3&gt;
  
  
  Computer architecture
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CPU
Registers
Memory
Cache
Instructions
Stack
Heap
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Operating systems
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Processes
Threads
Virtual memory
Filesystems
System calls
Scheduling
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Data structures
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Arrays
Linked lists
Trees
Hash tables
Graphs
Heaps
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Algorithms
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Searching
Sorting
Traversal
Recursion
Dynamic programming
Graph algorithms
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Programming languages
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Parsing
Compilation
Runtime
Memory management
Type systems
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The more you understand these foundations, the easier it becomes to recognize when generated code doesn't make sense.&lt;/p&gt;




&lt;h2&gt;
  
  
  AI Changes the Value of Programming Skills
&lt;/h2&gt;

&lt;p&gt;AI may reduce the amount of time programmers spend typing repetitive code.&lt;/p&gt;

&lt;p&gt;That doesn't necessarily make programming less important.&lt;/p&gt;

&lt;p&gt;It can make &lt;strong&gt;reasoning more important&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Imagine two programmers.&lt;/p&gt;

&lt;p&gt;Programmer A can write code extremely quickly but accepts generated code without questioning it.&lt;/p&gt;

&lt;p&gt;Programmer B writes code more deliberately but understands:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;requirements
architecture
algorithms
constraints
security
performance
failure modes
testing
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As code generation becomes easier, the ability to determine &lt;strong&gt;what code should exist in the first place&lt;/strong&gt; becomes increasingly valuable.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Programmer's New Superpower
&lt;/h2&gt;

&lt;p&gt;The future programmer doesn't necessarily need to type every line manually.&lt;/p&gt;

&lt;p&gt;Instead, they need to be able to:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Understand the problem
        ↓
Break it into smaller problems
        ↓
Design a solution
        ↓
Use AI to accelerate implementation
        ↓
Review the generated code
        ↓
Test it
        ↓
Find hidden assumptions
        ↓
Improve the design
        ↓
Verify the final system
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;AI can dramatically accelerate the implementation stage.&lt;/p&gt;

&lt;p&gt;But the programmer still needs to control the reasoning process.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Question Isn't "Can AI Write Code?"
&lt;/h2&gt;

&lt;p&gt;That question is becoming less interesting.&lt;/p&gt;

&lt;p&gt;A better question is:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Can you understand the code well enough to know when it is wrong?&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Because software isn't valuable simply because it exists.&lt;/p&gt;

&lt;p&gt;It has to satisfy requirements.&lt;/p&gt;

&lt;p&gt;It has to behave correctly.&lt;/p&gt;

&lt;p&gt;It has to handle failures.&lt;/p&gt;

&lt;p&gt;It has to respect constraints.&lt;/p&gt;

&lt;p&gt;It has to be maintainable.&lt;/p&gt;

&lt;p&gt;And in many systems, it has to be secure.&lt;/p&gt;

&lt;p&gt;Those requirements create problems that cannot be solved merely by generating more code.&lt;/p&gt;




&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;AI is changing programming.&lt;/p&gt;

&lt;p&gt;There is no reason to ignore that.&lt;/p&gt;

&lt;p&gt;Use it.&lt;/p&gt;

&lt;p&gt;Ask it questions.&lt;/p&gt;

&lt;p&gt;Let it explain unfamiliar APIs.&lt;/p&gt;

&lt;p&gt;Let it generate boilerplate.&lt;/p&gt;

&lt;p&gt;Let it help you debug.&lt;/p&gt;

&lt;p&gt;Let it suggest alternatives.&lt;/p&gt;

&lt;p&gt;But don't outsource your understanding.&lt;/p&gt;

&lt;p&gt;When AI gives you code, ask:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Why does this work?

What assumptions does it make?

When does it fail?

What happens at the boundaries?

Can I test it?

Can I explain it?

Would I design it this way myself?

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

&lt;/div&gt;



&lt;p&gt;The strongest programmer in the AI era may not be the person who can type the fastest.&lt;/p&gt;

&lt;p&gt;It may be the person who can &lt;strong&gt;think most clearly about the problem&lt;/strong&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;AI can generate code.&lt;br&gt;
Critical thinking determines whether that code deserves to exist.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>productivity</category>
      <category>ai</category>
      <category>code</category>
      <category>programming</category>
    </item>
    <item>
      <title>Flat Assembler (FASM): A Practical Introduction to Low-Level Programming</title>
      <dc:creator>Farhad Rahimi Klie</dc:creator>
      <pubDate>Fri, 11 Sep 2026 10:25:35 +0000</pubDate>
      <link>https://dev.to/farhadrahimiklie/-flat-assembler-fasm-a-practical-introduction-to-low-level-programming-o3h</link>
      <guid>https://dev.to/farhadrahimiklie/-flat-assembler-fasm-a-practical-introduction-to-low-level-programming-o3h</guid>
      <description>&lt;p&gt;If you are interested in operating systems, compilers, reverse engineering, embedded systems, executable formats, or simply understanding how computers work at a low level, learning assembly language can be extremely valuable.&lt;/p&gt;

&lt;p&gt;There are many assemblers available today, but one that deserves special attention is &lt;strong&gt;Flat Assembler&lt;/strong&gt;, commonly called &lt;strong&gt;FASM&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;FASM is a fast, powerful, and flexible assembler that gives you a very direct relationship with the machine code generated by your program.&lt;/p&gt;

&lt;p&gt;In this article, we'll look at what FASM is, how it works, why it is interesting, and what you can build with it.&lt;/p&gt;




&lt;h2&gt;
  
  
  What Is Flat Assembler?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Flat Assembler (FASM)&lt;/strong&gt; is an assembler for the x86 and x86-64 architectures.&lt;/p&gt;

&lt;p&gt;An assembler converts assembly language instructions into machine code that the CPU can execute.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mov rax, 60
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The CPU does not actually understand the text:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mov rax, 60
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Instead, FASM translates the instruction into machine-code bytes.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Assembly source
      |
      v
     FASM
      |
      v
 Machine code
      |
      v
 Executable
      |
      v
     CPU
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is the fundamental job of an assembler.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why Is FASM Interesting?
&lt;/h2&gt;

&lt;p&gt;FASM has several characteristics that make it different from many other assemblers.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. It is self-hosting
&lt;/h3&gt;

&lt;p&gt;FASM is written in assembly language.&lt;/p&gt;

&lt;p&gt;That alone makes it an interesting project for people who want to study low-level programming.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. It has a powerful macro system
&lt;/h3&gt;

&lt;p&gt;FASM's macro system allows you to build your own higher-level abstractions while still working with assembly.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;macro exit {
    mov rax, 60
    xor rdi, rdi
    syscall
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;exit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;FASM expands the macro during assembly.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. It can generate different executable formats
&lt;/h3&gt;

&lt;p&gt;FASM supports multiple output formats.&lt;/p&gt;

&lt;p&gt;For example, you can create:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;format ELF64 executable
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;for a Linux x86-64 executable.&lt;/p&gt;

&lt;p&gt;You can also work with Windows PE formats and other output types.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. It gives you direct control
&lt;/h3&gt;

&lt;p&gt;FASM does not try to hide the machine.&lt;/p&gt;

&lt;p&gt;You can explicitly work with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;registers&lt;/li&gt;
&lt;li&gt;memory&lt;/li&gt;
&lt;li&gt;instructions&lt;/li&gt;
&lt;li&gt;sections&lt;/li&gt;
&lt;li&gt;symbols&lt;/li&gt;
&lt;li&gt;addresses&lt;/li&gt;
&lt;li&gt;stack frames&lt;/li&gt;
&lt;li&gt;calling conventions&lt;/li&gt;
&lt;li&gt;system calls&lt;/li&gt;
&lt;li&gt;executable formats&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This makes it excellent for learning how software actually works.&lt;/p&gt;




&lt;h2&gt;
  
  
  FASM vs NASM
&lt;/h2&gt;

&lt;p&gt;If you have already learned or seen NASM, you may wonder:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Why learn FASM instead?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Both are excellent assemblers, but their philosophies differ.&lt;/p&gt;

&lt;p&gt;A simplified comparison:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Feature&lt;/th&gt;
&lt;th&gt;FASM&lt;/th&gt;
&lt;th&gt;NASM&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;x86/x86-64&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Linux&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Windows&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Powerful macros&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Multiple output formats&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Direct machine-level control&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Self-hosting implementation&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Minimal syntax&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The biggest reason to explore FASM is its &lt;strong&gt;macro system and overall design philosophy&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;FASM tries to provide powerful facilities while keeping the assembler itself relatively small and flexible.&lt;/p&gt;




&lt;h2&gt;
  
  
  Your First FASM Program
&lt;/h2&gt;

&lt;p&gt;Let's start with a simple Linux x86-64 program.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;format ELF64 executable

segment readable executable

entry main

main:
    mov rax, 60
    xor rdi, rdi
    syscall
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This program simply exits.&lt;/p&gt;

&lt;p&gt;Let's understand it.&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;code&gt;format&lt;/code&gt;
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;format ELF64 executable
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This tells FASM what kind of output we want.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ELF64
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;means a 64-bit Linux ELF executable.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;executable
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;means we want an executable file.&lt;/p&gt;

&lt;p&gt;So FASM knows how to construct the final executable.&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;code&gt;segment&lt;/code&gt;
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;segment readable executable
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This creates a segment containing executable code.&lt;/p&gt;

&lt;p&gt;The permissions indicate that the segment can be:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;readable
executable
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The CPU will execute instructions from this region.&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;code&gt;entry&lt;/code&gt;
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;entry main
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This tells FASM that &lt;code&gt;main&lt;/code&gt; is the entry point of the executable.&lt;/p&gt;

&lt;p&gt;In other words, when the operating system starts the program, execution begins at:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;main:
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Labels
&lt;/h2&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;main:
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;is a label.&lt;/p&gt;

&lt;p&gt;A label gives a name to a location in the program.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;main:
    mov rax, 60
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The label &lt;code&gt;main&lt;/code&gt; represents the address of that instruction.&lt;/p&gt;

&lt;p&gt;You can create other labels:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



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

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

&lt;/div&gt;



&lt;p&gt;Labels are extremely important in assembly programming.&lt;/p&gt;




&lt;h2&gt;
  
  
  Registers
&lt;/h2&gt;

&lt;p&gt;When programming x86-64 assembly, you will work heavily with registers.&lt;/p&gt;

&lt;p&gt;Some important registers include:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;RAX
RBX
RCX
RDX

RSI
RDI
RBP
RSP

R8
R9
R10
R11
R12
R13
R14
R15
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each register is a small, extremely fast storage location inside the CPU.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mov rax, 123
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;RAX = 123
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can then use the value:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;add rax, 10
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;RAX = 133
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  The &lt;code&gt;mov&lt;/code&gt; Instruction
&lt;/h2&gt;

&lt;p&gt;One of the most important instructions is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mov
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It copies data.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mov rax, 10
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;RAX &amp;lt;- 10
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mov rbx, rax
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;RBX &amp;lt;- RAX
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It is important to understand that &lt;code&gt;mov&lt;/code&gt; is fundamentally a &lt;strong&gt;copy&lt;/strong&gt; operation.&lt;/p&gt;




&lt;h2&gt;
  
  
  Memory
&lt;/h2&gt;

&lt;p&gt;Registers are very small.&lt;/p&gt;

&lt;p&gt;When you need larger amounts of data, you work with memory.&lt;/p&gt;

&lt;p&gt;FASM allows memory operands using brackets:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mov rax, [address]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The brackets mean:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Access the memory located at this address.&lt;/p&gt;
&lt;/blockquote&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mov rax, [rbx]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Use the value in RBX as an address
        |
        v
Memory[RBX]
        |
        v
       RAX
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mov rax, rbx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mov rax, [rbx]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The first copies the &lt;strong&gt;address/value stored in RBX&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The second reads the &lt;strong&gt;memory at the address stored in RBX&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;This distinction is fundamental in assembly.&lt;/p&gt;




&lt;h2&gt;
  
  
  Data Definitions
&lt;/h2&gt;

&lt;p&gt;FASM provides directives for creating data.&lt;/p&gt;

&lt;p&gt;Some important ones are:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;db
dw
dd
dq
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;They represent different data sizes.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;db&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;Define byte:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;db 10
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;code&gt;dw&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;Define word:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dw 10
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;code&gt;dd&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;Define double word:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dd 10
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;code&gt;dq&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;Define quad word:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dq 10
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You will use these constantly when creating data structures, buffers, strings, tables, and other binary data.&lt;/p&gt;




&lt;h2&gt;
  
  
  Strings
&lt;/h2&gt;

&lt;p&gt;A string can be defined using:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;message db 'Hello, world!', 0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;0&lt;/code&gt; is important when you want the string to be compatible with C-style null-terminated strings.&lt;/p&gt;

&lt;p&gt;Memory might look like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;H e l l o ,   w o r l d !
48 65 6C 6C 6F ...
                     |
                     v
                     00
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The zero byte marks the end of the string.&lt;/p&gt;




&lt;h2&gt;
  
  
  Reserving Memory
&lt;/h2&gt;

&lt;p&gt;FASM also provides declarations for reserving space.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;buffer rb 100
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;means:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Reserve 100 bytes.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Other declarations include:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rw
rd
rq
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These are useful when creating buffers and data structures.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;buffer rb 4096
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;creates a 4096-byte buffer.&lt;/p&gt;




&lt;h2&gt;
  
  
  Arithmetic
&lt;/h2&gt;

&lt;p&gt;FASM supports the normal x86 arithmetic instructions.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mov rax, 20
add rax, 5
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;RAX = 25
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sub rax, 10
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;inc rax
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dec rax
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;neg rax
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also perform multiplication and division with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mul
imul
div
idiv
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These instructions require more attention because some of them use implicit registers.&lt;/p&gt;




&lt;h2&gt;
  
  
  Bitwise Operations
&lt;/h2&gt;

&lt;p&gt;Assembly programming also involves manipulating individual bits.&lt;/p&gt;

&lt;p&gt;Important instructions include:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;and
or
xor
not
shl
shr
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;xor rax, rax
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;is a very common instruction.&lt;/p&gt;

&lt;p&gt;It sets:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;RAX = 0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;x XOR x = 0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Comparing Values
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;cmp&lt;/code&gt; instruction is extremely important.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cmp rax, rbx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Conceptually, the CPU calculates:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;RAX - RBX
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;but does not store the result.&lt;/p&gt;

&lt;p&gt;Instead, it updates CPU flags.&lt;/p&gt;

&lt;p&gt;Those flags can then be used by conditional jumps.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cmp rax, rbx
je equal
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the values are equal, execution jumps to:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;equal:
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Control Flow
&lt;/h2&gt;

&lt;p&gt;Assembly programs need branches and loops.&lt;/p&gt;

&lt;p&gt;The basic unconditional jump is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;jmp label
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;jmp start

start:
    ...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Conditional jumps include:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;je
jne
jg
jge
jl
jle
ja
jb
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These are based on CPU flags.&lt;/p&gt;

&lt;p&gt;You will eventually learn the important difference between:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;signed comparisons
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;unsigned comparisons
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;because instructions such as &lt;code&gt;jg&lt;/code&gt; and &lt;code&gt;ja&lt;/code&gt; do not mean the same thing.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Stack
&lt;/h2&gt;

&lt;p&gt;The stack is one of the most important concepts in assembly.&lt;/p&gt;

&lt;p&gt;The stack is an area of memory used for temporary data and function calls.&lt;/p&gt;

&lt;p&gt;Two important registers are:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;RSP
RBP
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;RSP&lt;/code&gt; is the stack pointer.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;RBP&lt;/code&gt; is commonly used as a frame pointer.&lt;/p&gt;

&lt;p&gt;You can place a value onto the stack:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;push rax
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and retrieve it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pop rax
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Function calls also use the stack.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;call my_function
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The CPU saves a return address and jumps to:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;my_function:
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ret
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;returns to the caller.&lt;/p&gt;

&lt;p&gt;Understanding &lt;code&gt;call&lt;/code&gt;, &lt;code&gt;ret&lt;/code&gt;, &lt;code&gt;push&lt;/code&gt;, &lt;code&gt;pop&lt;/code&gt;, and &lt;code&gt;rsp&lt;/code&gt; is essential for writing functions in assembly.&lt;/p&gt;




&lt;h2&gt;
  
  
  Functions
&lt;/h2&gt;

&lt;p&gt;A function can be created manually:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;my_function:
    mov rax, 123
    ret
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can call it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;call my_function
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The general flow is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;caller
  |
  | call
  v
my_function
  |
  | ret
  v
caller
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At this level, you begin to understand how higher-level languages implement functions underneath.&lt;/p&gt;




&lt;h2&gt;
  
  
  Linux System Calls
&lt;/h2&gt;

&lt;p&gt;One of the most interesting parts of Linux assembly programming is using system calls directly.&lt;/p&gt;

&lt;p&gt;For x86-64 Linux, the &lt;code&gt;syscall&lt;/code&gt; instruction enters the kernel.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mov rax, 60
mov rdi, 0
syscall
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This requests the &lt;code&gt;exit&lt;/code&gt; system call.&lt;/p&gt;

&lt;p&gt;The general idea is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Your program
     |
     | syscall
     v
Linux kernel
     |
     v
Operating-system service
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;System calls allow assembly programs to communicate directly with the operating system without necessarily going through the C standard library.&lt;/p&gt;




&lt;h2&gt;
  
  
  FASM Macros
&lt;/h2&gt;

&lt;p&gt;One of FASM's most powerful features is its macro system.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;macro exit {
    mov rax, 60
    xor rdi, rdi
    syscall
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you can write:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;exit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;instead of repeatedly writing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mov rax, 60
xor rdi, rdi
syscall
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This becomes especially useful for larger assembly projects.&lt;/p&gt;

&lt;p&gt;FASM provides several powerful macro-related mechanisms, including:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;macro
match
rept
repeat
irp
irps
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These allow you to build abstractions and even create small domain-specific languages inside assembly.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why Learn FASM Macros?
&lt;/h2&gt;

&lt;p&gt;At first, assembly can become repetitive.&lt;/p&gt;

&lt;p&gt;For example, imagine repeatedly writing system-call setup code.&lt;/p&gt;

&lt;p&gt;Macros allow you to create your own abstractions.&lt;/p&gt;

&lt;p&gt;You could eventually create something like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;print_string message, message_length
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;which expands into the appropriate instructions.&lt;/p&gt;

&lt;p&gt;The CPU still receives ordinary machine code.&lt;/p&gt;

&lt;p&gt;The macro exists only during assembly.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Your FASM source
       |
       v
     Macros
       |
       v
 Expanded assembly
       |
       v
 Machine code
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is one of the reasons FASM is so interesting.&lt;/p&gt;




&lt;h2&gt;
  
  
  FASM Structures
&lt;/h2&gt;

&lt;p&gt;FASM also allows you to define structures.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;struc Person {
    .age dd ?
    .id  dd ?
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can then use structure layouts to organize memory.&lt;/p&gt;

&lt;p&gt;This becomes particularly useful when working with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;operating-system structures&lt;/li&gt;
&lt;li&gt;executable formats&lt;/li&gt;
&lt;li&gt;network packets&lt;/li&gt;
&lt;li&gt;file formats&lt;/li&gt;
&lt;li&gt;hardware structures&lt;/li&gt;
&lt;li&gt;custom data structures&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Instead of thinking only in individual variables, you can start thinking in terms of &lt;strong&gt;memory layouts&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  Address Expressions
&lt;/h2&gt;

&lt;p&gt;FASM supports powerful address expressions.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mov rax, [rbx + rcx*8]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This can be understood as:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;address = RBX + RCX * 8
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;RAX = Memory[address]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This type of addressing is extremely important for arrays.&lt;/p&gt;

&lt;p&gt;Suppose each element is 8 bytes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;array[0] -&amp;gt; address + 0
array[1] -&amp;gt; address + 8
array[2] -&amp;gt; address + 16
array[3] -&amp;gt; address + 24
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mov rax, [rbx + rcx*8]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;can access an element based on &lt;code&gt;RCX&lt;/code&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  FASM and Executable Formats
&lt;/h2&gt;

&lt;p&gt;One of the fascinating things about assembly programming is that you eventually discover that an executable is not simply "machine code."&lt;/p&gt;

&lt;p&gt;An executable contains structures describing:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;entry points&lt;/li&gt;
&lt;li&gt;sections&lt;/li&gt;
&lt;li&gt;memory permissions&lt;/li&gt;
&lt;li&gt;imported libraries&lt;/li&gt;
&lt;li&gt;relocation information&lt;/li&gt;
&lt;li&gt;program headers&lt;/li&gt;
&lt;li&gt;metadata&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For example, Linux commonly uses:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ELF
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;while Windows commonly uses:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PE
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;FASM can construct these executable formats.&lt;/p&gt;

&lt;p&gt;This makes FASM useful for learning not only assembly instructions, but also how executable files are structured.&lt;/p&gt;




&lt;h2&gt;
  
  
  What Can You Build With FASM?
&lt;/h2&gt;

&lt;p&gt;FASM is not limited to tiny examples.&lt;/p&gt;

&lt;p&gt;You can use it to build serious low-level projects.&lt;/p&gt;

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

&lt;h3&gt;
  
  
  Small programs
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CLI tools
calculators
text utilities
file utilities
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Systems programming
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;bootloaders
kernel components
runtime libraries
system utilities
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Binary programming
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ELF files
PE files
custom binary formats
binary parsers
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Educational projects
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CPU experiments
memory allocators
custom data structures
assembly implementations of algorithms
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Advanced projects
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;operating-system components
compilers
virtual machines
debuggers
JIT systems
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The difficulty varies enormously, but FASM gives you the low-level control required for these types of projects.&lt;/p&gt;




&lt;h2&gt;
  
  
  A Good Way to Learn FASM
&lt;/h2&gt;

&lt;p&gt;Don't try to memorize hundreds of instructions immediately.&lt;/p&gt;

&lt;p&gt;A better approach is to build your understanding in layers.&lt;/p&gt;

&lt;h2&gt;
  
  
  Layer 1 — CPU Fundamentals
&lt;/h2&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Registers
RAX
RBX
RCX
RDX
RSI
RDI
RSP
RBP
R8-R15
RIP
RFLAGS
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Understand the difference between:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;64-bit
32-bit
16-bit
8-bit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Layer 2 — Basic Instructions
&lt;/h2&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mov
add
sub
inc
dec
neg
mul
imul
div
idiv
and
or
xor
not
shl
shr
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Layer 3 — Control Flow
&lt;/h2&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cmp
test
jmp
je
jne
jg
jge
jl
jle
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then learn loops.&lt;/p&gt;




&lt;h2&gt;
  
  
  Layer 4 — Memory
&lt;/h2&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;addresses
pointers
dereferencing
memory operands
arrays
structures
address expressions
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mov rax, [rbx + rcx*8]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;should eventually become completely natural to you.&lt;/p&gt;




&lt;h2&gt;
  
  
  Layer 5 — Stack and Functions
&lt;/h2&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;push
pop
call
ret
rsp
rbp
stack frames
calling conventions
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is where assembly begins to connect strongly with C.&lt;/p&gt;




&lt;h2&gt;
  
  
  Layer 6 — Operating System Interface
&lt;/h2&gt;

&lt;p&gt;On Linux, learn:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;syscall
system-call numbers
register conventions
file descriptors
read
write
open
close
exit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then build programs without relying on a C runtime.&lt;/p&gt;




&lt;h2&gt;
  
  
  Layer 7 — FASM Features
&lt;/h2&gt;

&lt;p&gt;After understanding the CPU itself, learn FASM-specific features:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;format
include
sections/segments
constants
data definitions
structures
macros
match
repeat
rept
irp
irps
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is where you start taking advantage of FASM rather than treating it like a generic assembler.&lt;/p&gt;




&lt;h2&gt;
  
  
  FASM Is More Than "Writing Assembly"
&lt;/h2&gt;

&lt;p&gt;The most important thing to understand is that learning FASM is not just about memorizing instructions.&lt;/p&gt;

&lt;p&gt;You are learning several layers simultaneously:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;                Your Program
                     |
                     v
              FASM source code
                     |
                     v
              FASM assembler
                     |
                     v
               Machine code
                     |
                     v
                 CPU / OS
                     |
                     v
                  Hardware
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you become more comfortable, you will start seeing how all these layers connect.&lt;/p&gt;

&lt;p&gt;A C program such as:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;eventually becomes machine instructions.&lt;/p&gt;

&lt;p&gt;An operating system eventually interacts with hardware through machine-level mechanisms.&lt;/p&gt;

&lt;p&gt;An executable eventually becomes bytes arranged according to a binary format.&lt;/p&gt;

&lt;p&gt;Assembly sits very close to that boundary.&lt;/p&gt;




&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;Flat Assembler is an excellent choice if your goal is to understand computers at a low level.&lt;/p&gt;

&lt;p&gt;It teaches you to think about:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;registers&lt;/li&gt;
&lt;li&gt;memory&lt;/li&gt;
&lt;li&gt;addresses&lt;/li&gt;
&lt;li&gt;instructions&lt;/li&gt;
&lt;li&gt;CPU flags&lt;/li&gt;
&lt;li&gt;stacks&lt;/li&gt;
&lt;li&gt;functions&lt;/li&gt;
&lt;li&gt;calling conventions&lt;/li&gt;
&lt;li&gt;system calls&lt;/li&gt;
&lt;li&gt;executable formats&lt;/li&gt;
&lt;li&gt;machine code&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And FASM's macro system gives you something especially interesting: the ability to build powerful abstractions while remaining very close to the machine.&lt;/p&gt;

&lt;p&gt;If you are coming from C, FASM can also change the way you understand C itself.&lt;/p&gt;

&lt;p&gt;Instead of seeing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="n"&gt;function&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;you begin asking:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;How is the function called?
Where are the arguments?
Which registers contain them?
What happens to the stack?
Where does the return address go?
How is the return value produced?
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That is where assembly becomes truly valuable.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Don't learn assembly just to write assembly. Learn it to understand what your computer is actually doing.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;And if you choose FASM, you get a particularly interesting tool for exploring that world.&lt;/p&gt;

</description>
      <category>assembly</category>
      <category>code</category>
      <category>lowcode</category>
      <category>farhadrahimiklie</category>
    </item>
    <item>
      <title>How to Install a Linux Distro Using WSL on Windows</title>
      <dc:creator>Farhad Rahimi Klie</dc:creator>
      <pubDate>Fri, 04 Sep 2026 06:39:00 +0000</pubDate>
      <link>https://dev.to/farhadrahimiklie/how-to-install-a-linux-distro-using-wsl-on-windows-3mo5</link>
      <guid>https://dev.to/farhadrahimiklie/how-to-install-a-linux-distro-using-wsl-on-windows-3mo5</guid>
      <description>&lt;p&gt;If you use Windows but want a Linux development environment, you don't necessarily need dual boot, a virtual machine, or a second computer.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Windows Subsystem for Linux (WSL)&lt;/strong&gt; lets you run a Linux distribution directly inside Windows.&lt;/p&gt;

&lt;p&gt;In this guide, we'll install WSL, choose a Linux distribution, create a Linux user, and verify that everything is working.&lt;/p&gt;




&lt;h2&gt;
  
  
  What Is WSL?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;WSL (Windows Subsystem for Linux)&lt;/strong&gt; is a Windows feature that allows you to run Linux distributions alongside Windows.&lt;/p&gt;

&lt;p&gt;You can use a Linux terminal and tools such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Bash&lt;/li&gt;
&lt;li&gt;Git&lt;/li&gt;
&lt;li&gt;GCC&lt;/li&gt;
&lt;li&gt;Python&lt;/li&gt;
&lt;li&gt;Rust&lt;/li&gt;
&lt;li&gt;Node.js&lt;/li&gt;
&lt;li&gt;Vim&lt;/li&gt;
&lt;li&gt;SSH&lt;/li&gt;
&lt;li&gt;Linux package managers&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;without installing Linux as a separate operating system.&lt;/p&gt;

&lt;p&gt;For developers, WSL is especially useful because you can keep Windows for your normal desktop applications while using Linux tools for development.&lt;/p&gt;




&lt;h2&gt;
  
  
  Requirements
&lt;/h2&gt;

&lt;p&gt;Before starting, make sure you're running a supported version of Windows.&lt;/p&gt;

&lt;p&gt;Open &lt;strong&gt;PowerShell&lt;/strong&gt; and run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;winver&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also check your Windows version with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;systeminfo&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For the easiest installation method, use a modern Windows 10 or Windows 11 system with WSL support.&lt;/p&gt;




&lt;h2&gt;
  
  
  1. Open PowerShell as Administrator
&lt;/h2&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Windows + X
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then select:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Windows PowerShell (Admin)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Terminal (Admin)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should see a terminal window with administrator privileges.&lt;/p&gt;




&lt;h2&gt;
  
  
  2. Install WSL
&lt;/h2&gt;

&lt;p&gt;The easiest method is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;wsl&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;--install&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command enables the required Windows components, installs the WSL components, and normally installs Ubuntu as the default Linux distribution.&lt;/p&gt;

&lt;p&gt;After installation, Windows may ask you to restart your computer.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;shutdown&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;/r&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;/t&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;0&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After Windows starts again, the Linux distribution setup should continue.&lt;/p&gt;




&lt;h2&gt;
  
  
  3. Check Available Linux Distributions
&lt;/h2&gt;

&lt;p&gt;You don't have to use Ubuntu.&lt;/p&gt;

&lt;p&gt;To see the distributions available through WSL, run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;wsl&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;--list&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;--online&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You may see distributions such as:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;NAME
Ubuntu
Debian
kali-linux
openSUSE-Tumbleweed
Ubuntu-24.04
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The exact list can change over time.&lt;/p&gt;




&lt;h2&gt;
  
  
  4. Install a Specific Linux Distribution
&lt;/h2&gt;

&lt;p&gt;For example, to install Ubuntu:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;wsl&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;--install&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;-d&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;Ubuntu&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or, if you want Debian:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;wsl&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;--install&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;-d&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;Debian&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can replace the distribution name with one from:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;wsl&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;--list&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;--online&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;wsl&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;--install&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;-d&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;Ubuntu-24.04&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  5. Create Your Linux User
&lt;/h2&gt;

&lt;p&gt;After the distribution starts for the first time, Linux will ask you to create a username.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Enter new UNIX username:
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You might enter:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;farhad
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then create a password.&lt;/p&gt;

&lt;p&gt;When typing the password, &lt;strong&gt;nothing will appear on the screen&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;That's normal behavior in Linux terminals.&lt;/p&gt;

&lt;p&gt;Type the password and press Enter.&lt;/p&gt;




&lt;h2&gt;
  
  
  6. Verify the Installation
&lt;/h2&gt;

&lt;p&gt;Inside your Linux terminal, run:&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;uname&lt;/span&gt; &lt;span class="nt"&gt;-a&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then:&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;cat&lt;/span&gt; /etc/os-release
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should see information about your Linux distribution.&lt;/p&gt;

&lt;p&gt;You can also check the current user:&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;whoami&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And check your home directory:&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;pwd&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should get something similar to:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/home/farhad
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Your Linux environment is now running.&lt;/p&gt;




&lt;h2&gt;
  
  
  7. Check WSL From Windows
&lt;/h2&gt;

&lt;p&gt;Close the Linux terminal and open PowerShell.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;wsl&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;--list&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;--verbose&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should see something similar to:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  NAME      STATE           VERSION
* Ubuntu    Running         2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The important part is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;VERSION
2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That means you're using &lt;strong&gt;WSL 2&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;WSL 2 uses a lightweight virtualized Linux environment and provides much better Linux compatibility than the original WSL 1 architecture.&lt;/p&gt;




&lt;h2&gt;
  
  
  8. Start Your Linux Distribution
&lt;/h2&gt;

&lt;p&gt;You can start your default distribution by simply running:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;wsl&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or you can specify a distribution:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;wsl&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;-d&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;Ubuntu&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;wsl&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;-d&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;Debian&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also see installed distributions with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;wsl&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;-l&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  9. Update Linux
&lt;/h2&gt;

&lt;p&gt;After installing Linux, update its package information.&lt;/p&gt;

&lt;p&gt;For Ubuntu or Debian:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt update
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then upgrade installed packages:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt upgrade
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can combine them:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt update &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;sudo &lt;/span&gt;apt upgrade
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It's a good idea to do this before installing development tools.&lt;/p&gt;




&lt;h2&gt;
  
  
  10. Access Windows Files From Linux
&lt;/h2&gt;

&lt;p&gt;One of the useful features of WSL is that you can access your Windows drives.&lt;/p&gt;

&lt;p&gt;Your Windows &lt;code&gt;C:&lt;/code&gt; drive is normally available at:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/mnt/c
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; /mnt/c
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can see your Windows files:&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;p&gt;Your Windows user directory might be accessible through:&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;cd&lt;/span&gt; /mnt/c/Users
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This makes it possible to work between Windows and Linux.&lt;/p&gt;




&lt;h2&gt;
  
  
  11. Access Linux Files From Windows
&lt;/h2&gt;

&lt;p&gt;WSL also provides a way to access your Linux filesystem from Windows.&lt;/p&gt;

&lt;p&gt;From Windows File Explorer, you can enter:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;\\wsl$
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;in the address bar.&lt;/p&gt;

&lt;p&gt;You should see your installed WSL distributions.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;\\wsl$\Ubuntu
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This allows Windows applications to interact with files inside your Linux environment.&lt;/p&gt;

&lt;p&gt;For development projects, however, it's generally best to keep Linux-oriented projects inside the Linux filesystem rather than constantly working across &lt;code&gt;/mnt/c&lt;/code&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  12. Install Development Tools
&lt;/h2&gt;

&lt;p&gt;Now you can use Linux normally.&lt;/p&gt;

&lt;p&gt;For example, install Git:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;git
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Install GCC:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;build-essential
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Check GCC:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;gcc &lt;span class="nt"&gt;--version&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Install Vim:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;vim
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you have a basic Linux development environment running inside Windows.&lt;/p&gt;




&lt;h2&gt;
  
  
  Installing Another Distribution Later
&lt;/h2&gt;

&lt;p&gt;You can install multiple Linux distributions on the same Windows installation.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;wsl&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;--install&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;-d&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;Debian&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then check them:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;wsl&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;--list&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;--verbose&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You might have:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  NAME      STATE           VERSION
* Ubuntu    Stopped         2
  Debian    Stopped         2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can start Debian with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;wsl&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;-d&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;Debian&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Making a Distribution Your Default
&lt;/h2&gt;

&lt;p&gt;If you have multiple distributions installed, you can choose which one starts when you run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;wsl&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;wsl&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;--set-default&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;Debian&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;wsl&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;will start Debian by default.&lt;/p&gt;




&lt;h2&gt;
  
  
  Useful WSL Commands
&lt;/h2&gt;

&lt;p&gt;Here are some commands you'll use frequently.&lt;/p&gt;

&lt;h3&gt;
  
  
  List installed distributions
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;wsl&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;--list&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;--verbose&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  List available distributions
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;wsl&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;--list&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;--online&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Start WSL
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;wsl&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Start a specific distribution
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;wsl&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;-d&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;Ubuntu&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Shut down WSL
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;wsl&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;--shutdown&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Stop a specific distribution
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;wsl&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;--terminate&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;Ubuntu&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Check WSL version
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;wsl&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;--version&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Update WSL
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;wsl&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;--update&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Set the default distribution
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;wsl&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;--set-default&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;Ubuntu&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Common Problems
&lt;/h2&gt;

&lt;h2&gt;
  
  
  &lt;code&gt;wsl --install&lt;/code&gt; Doesn't Work
&lt;/h2&gt;

&lt;p&gt;First check whether WSL is available:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;wsl&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;--status&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then try:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;wsl&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;--update&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You may also need to enable Windows virtualization features or restart Windows after enabling WSL.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Distribution Download Fails
&lt;/h2&gt;

&lt;p&gt;If you receive a network-related error while installing a distribution, check your internet connection first.&lt;/p&gt;

&lt;p&gt;You can also check the available distributions:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;wsl&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;--list&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;--online&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then retry the installation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;wsl&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;--install&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;-d&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;Debian&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Check Whether Virtualization Is Enabled
&lt;/h2&gt;

&lt;p&gt;Open Task Manager:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Ctrl + Shift + Esc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Go to:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Performance → CPU
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Look for:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Virtualization: Enabled
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If virtualization is disabled, you may need to enable the appropriate virtualization setting in your computer's UEFI/BIOS.&lt;/p&gt;




&lt;h2&gt;
  
  
  WSL vs Dual Boot
&lt;/h2&gt;

&lt;p&gt;WSL and dual boot solve different problems.&lt;/p&gt;

&lt;p&gt;With &lt;strong&gt;dual boot&lt;/strong&gt;, you install Windows and Linux as separate operating systems and choose one when the computer starts.&lt;/p&gt;

&lt;p&gt;With &lt;strong&gt;WSL&lt;/strong&gt;, Linux runs alongside Windows.&lt;/p&gt;

&lt;p&gt;For development, WSL can be much more convenient because you don't need to reboot your computer every time you want to use Linux.&lt;/p&gt;

&lt;p&gt;A simple setup might look like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Windows
   │
   └── WSL 2
        │
        ├── Ubuntu
        ├── Debian
        └── Other Linux distributions
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






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

&lt;p&gt;Installing Linux with WSL is one of the easiest ways to get a Linux development environment on Windows.&lt;/p&gt;

&lt;p&gt;The basic workflow is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;wsl&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;--install&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;wsl&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;--list&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;--online&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Choose a distribution:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;wsl&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;--install&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;-d&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;Ubuntu&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Start it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;wsl&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And verify it:&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;uname&lt;/span&gt; &lt;span class="nt"&gt;-a&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once it's installed, you can use Linux tools, package managers, compilers, Git, editors, programming languages, and other development tools directly from Windows.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Windows doesn't have to mean giving up the Linux development environment. With WSL, you can have both.&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>linux</category>
      <category>cli</category>
      <category>wsl</category>
      <category>farhadrahimiklie</category>
    </item>
    <item>
      <title>The Philosophy of Rust Programming Language</title>
      <dc:creator>Farhad Rahimi Klie</dc:creator>
      <pubDate>Wed, 26 Aug 2026 10:57:52 +0000</pubDate>
      <link>https://dev.to/farhadrahimiklie/the-philosophy-of-rust-programming-language-2n3j</link>
      <guid>https://dev.to/farhadrahimiklie/the-philosophy-of-rust-programming-language-2n3j</guid>
      <description>&lt;p&gt;Rust is often introduced as a &lt;strong&gt;fast, memory-safe systems programming language&lt;/strong&gt;. That description is correct, but it does not explain what makes Rust fundamentally different.&lt;/p&gt;

&lt;p&gt;Rust is built around a powerful idea:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;What if we could write low-level, high-performance software while preventing many of the most dangerous programming mistakes before the program even runs?&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That question defines much of Rust's philosophy.&lt;/p&gt;

&lt;p&gt;Rust is not simply “C with modern syntax,” and it is not trying to replace every programming language. It takes a different approach to systems programming: use the compiler and type system to enforce important correctness guarantees while still giving programmers control over memory, performance, and the machine.&lt;/p&gt;

&lt;p&gt;Let's explore the philosophy behind Rust.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Memory Safety Without a Garbage Collector
&lt;/h2&gt;

&lt;p&gt;Traditional systems programming languages such as C give programmers direct control over memory.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;ptr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;malloc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;sizeof&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;

&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;ptr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;42&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="n"&gt;free&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ptr&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This level of control is powerful, but it also creates responsibility. A programmer can accidentally:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Access memory after it has been freed&lt;/li&gt;
&lt;li&gt;Free the same memory twice&lt;/li&gt;
&lt;li&gt;Use an invalid pointer&lt;/li&gt;
&lt;li&gt;Forget to free allocated memory&lt;/li&gt;
&lt;li&gt;Create memory corruption&lt;/li&gt;
&lt;/ul&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;ptr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;malloc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;sizeof&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;

&lt;span class="n"&gt;free&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ptr&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="n"&gt;printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"%d&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;ptr&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A C compiler may allow this code to compile even though using &lt;code&gt;ptr&lt;/code&gt; after &lt;code&gt;free()&lt;/code&gt; is invalid.&lt;/p&gt;

&lt;p&gt;Rust takes a different approach.&lt;/p&gt;

&lt;p&gt;Rust wants to prevent many of these problems &lt;strong&gt;before the program runs&lt;/strong&gt;, without requiring a garbage collector.&lt;/p&gt;

&lt;p&gt;The core mechanism behind this is Rust's ownership system.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nn"&gt;Box&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;new&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;42&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When &lt;code&gt;value&lt;/code&gt; goes out of scope, Rust automatically cleans up the memory.&lt;/p&gt;

&lt;p&gt;The important part is that this cleanup is determined through Rust's ownership rules rather than a background garbage collector.&lt;/p&gt;

&lt;p&gt;Rust's philosophy is:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Memory safety should not require sacrificing systems-level performance.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  2. Ownership: Every Resource Should Have Clear Responsibility
&lt;/h2&gt;

&lt;p&gt;One of Rust's most important ideas is &lt;strong&gt;ownership&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;In languages like C, ownership is often a convention.&lt;/p&gt;

&lt;p&gt;Consider a function:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="kt"&gt;char&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="nf"&gt;create_name&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;void&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Who is responsible for freeing the returned memory?&lt;/p&gt;

&lt;p&gt;The caller?&lt;/p&gt;

&lt;p&gt;The function?&lt;/p&gt;

&lt;p&gt;Another part of the program?&lt;/p&gt;

&lt;p&gt;Usually, the answer must be documented and remembered by the programmer.&lt;/p&gt;

&lt;p&gt;Rust makes ownership part of the language.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nn"&gt;String&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;from&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Rust"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The variable &lt;code&gt;name&lt;/code&gt; owns the &lt;code&gt;String&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Ownership can also move:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="n"&gt;name1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nn"&gt;String&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;from&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Rust"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="n"&gt;name2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;name1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After this move, &lt;code&gt;name1&lt;/code&gt; can no longer be used.&lt;/p&gt;

&lt;p&gt;This may initially feel restrictive to programmers coming from C or C++, but there is a reason.&lt;/p&gt;

&lt;p&gt;Rust prevents multiple parts of a program from incorrectly believing that they own the same resource.&lt;/p&gt;

&lt;p&gt;The philosophy is simple:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;If a resource has a clear owner, its lifetime becomes easier to reason about.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Ownership allows Rust to automatically manage resources while preventing many categories of memory errors.&lt;/p&gt;




&lt;h2&gt;
  
  
  3. Borrowing: Access Without Ownership
&lt;/h2&gt;

&lt;p&gt;Not every function needs to take ownership of data.&lt;/p&gt;

&lt;p&gt;Sometimes a function only needs temporary access.&lt;/p&gt;

&lt;p&gt;Rust solves this with &lt;strong&gt;borrowing&lt;/strong&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="k"&gt;fn&lt;/span&gt; &lt;span class="nf"&gt;print_name&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="nb"&gt;String&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nd"&gt;println!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"{name}"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The function borrows the &lt;code&gt;String&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;It can access the data without becoming its owner.&lt;/p&gt;

&lt;p&gt;Rust distinguishes between immutable and mutable borrowing.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nn"&gt;String&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;from&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Rust"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="n"&gt;reference&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This creates an immutable reference.&lt;/p&gt;

&lt;p&gt;For mutable access:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="k"&gt;mut&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nn"&gt;String&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;from&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Rust"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="n"&gt;reference&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="k"&gt;mut&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Rust carefully controls how references can coexist.&lt;/p&gt;

&lt;p&gt;These rules may seem strict at first, but they exist to prevent problems such as invalid references and conflicting memory access.&lt;/p&gt;

&lt;p&gt;The deeper philosophy is:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Access to data should be explicit and constrained by rules that the compiler can verify.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  4. Make Invalid States Difficult to Represent
&lt;/h2&gt;

&lt;p&gt;Rust encourages programmers to model their programs using types.&lt;/p&gt;

&lt;p&gt;Suppose you are building a filesystem.&lt;/p&gt;

&lt;p&gt;In C, you might create something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="k"&gt;struct&lt;/span&gt; &lt;span class="n"&gt;Node&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;type&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kt"&gt;char&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;0 = File
1 = Directory
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But technically, the value could also be:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;999
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That represents an invalid state.&lt;/p&gt;

&lt;p&gt;Rust encourages you to model the possible states directly:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="k"&gt;enum&lt;/span&gt; &lt;span class="n"&gt;Node&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;File&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;u64&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;

    &lt;span class="n"&gt;Directory&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now a &lt;code&gt;Node&lt;/code&gt; can only be one of the states defined by the &lt;code&gt;enum&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;This is an important Rust design philosophy:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Represent the rules of your program in the type system.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Instead of checking for invalid states everywhere at runtime, Rust encourages you to design your data structures so that invalid states are difficult—or sometimes impossible—to construct.&lt;/p&gt;

&lt;p&gt;This becomes extremely valuable in large systems.&lt;/p&gt;




&lt;h2&gt;
  
  
  5. Absence Should Be Explicit
&lt;/h2&gt;

&lt;p&gt;Many programming languages use &lt;code&gt;null&lt;/code&gt; to represent the absence of a value.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;ptr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The danger is that the programmer may later forget to check whether the pointer is valid.&lt;/p&gt;

&lt;p&gt;Rust approaches this differently with &lt;code&gt;Option&amp;lt;T&amp;gt;&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Option&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nb"&gt;i32&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;Some&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;42&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Option&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nb"&gt;i32&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;None&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="k"&gt;enum&lt;/span&gt; &lt;span class="nb"&gt;Option&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;Some&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="nb"&gt;None&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The possibility that a value does not exist becomes part of its type.&lt;/p&gt;

&lt;p&gt;The programmer must handle that possibility.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="k"&gt;match&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;Some&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;number&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nd"&gt;println!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"{number}"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="nb"&gt;None&lt;/span&gt; &lt;span class="k"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nd"&gt;println!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"No value"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Rust's philosophy is:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;If something might not exist, represent that possibility explicitly.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  6. Errors Are Part of Normal Program Flow
&lt;/h2&gt;

&lt;p&gt;Rust treats recoverable errors as values.&lt;/p&gt;

&lt;p&gt;A function that might fail can return:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="nb"&gt;Result&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;E&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="k"&gt;enum&lt;/span&gt; &lt;span class="nb"&gt;Result&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;E&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;Ok&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="nf"&gt;Err&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;E&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="k"&gt;fn&lt;/span&gt; &lt;span class="nf"&gt;open_file&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="k"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;Result&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;File&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Error&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// ...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The function signature itself communicates something important:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;This operation may succeed or fail.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The caller must then decide how to handle both outcomes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="k"&gt;match&lt;/span&gt; &lt;span class="nf"&gt;open_file&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;Ok&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;file&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nd"&gt;println!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"File opened"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nf"&gt;Err&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nd"&gt;println!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Error: {error}"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Rust encourages programmers to think about failure during API design rather than treating errors as an afterthought.&lt;/p&gt;

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

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Failure is part of the program's model, so make it visible in the types.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  7. Zero-Cost Abstractions
&lt;/h2&gt;

&lt;p&gt;Rust is a systems programming language, so performance matters.&lt;/p&gt;

&lt;p&gt;At the same time, Rust provides modern abstractions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Iterators&lt;/li&gt;
&lt;li&gt;Generics&lt;/li&gt;
&lt;li&gt;Traits&lt;/li&gt;
&lt;li&gt;Closures&lt;/li&gt;
&lt;li&gt;Pattern matching&lt;/li&gt;
&lt;li&gt;Enums&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Rust's goal is to allow expressive code without automatically adding unnecessary runtime overhead.&lt;/p&gt;

&lt;p&gt;This idea is often called:&lt;/p&gt;

&lt;h2&gt;
  
  
  Zero-cost abstractions
&lt;/h2&gt;

&lt;p&gt;The basic philosophy is:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;High-level abstractions should not necessarily mean low performance.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;number&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;numbers&lt;/span&gt;&lt;span class="nf"&gt;.iter&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nd"&gt;println!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"{number}"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is much more expressive than manually managing an index or pointer.&lt;/p&gt;

&lt;p&gt;Rust aims to compile abstractions efficiently so that programmers can write clean, expressive code while maintaining systems-level performance.&lt;/p&gt;

&lt;p&gt;Of course, "zero-cost" does not mean every abstraction is magically free. It means Rust's abstractions are designed so that their cost should be predictable and should not impose unnecessary overhead when optimized.&lt;/p&gt;




&lt;h2&gt;
  
  
  8. Safe by Default, Unsafe by Explicit Choice
&lt;/h2&gt;

&lt;p&gt;Rust does not prevent you from performing low-level operations.&lt;/p&gt;

&lt;p&gt;In systems programming, sometimes you need:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Raw pointers&lt;/li&gt;
&lt;li&gt;Manual memory manipulation&lt;/li&gt;
&lt;li&gt;Operating system interfaces&lt;/li&gt;
&lt;li&gt;Hardware access&lt;/li&gt;
&lt;li&gt;Foreign Function Interfaces&lt;/li&gt;
&lt;li&gt;Custom allocators&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Rust provides these capabilities through &lt;code&gt;unsafe&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="k"&gt;unsafe&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Operations requiring additional safety guarantees&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The existence of &lt;code&gt;unsafe&lt;/code&gt; is important.&lt;/p&gt;

&lt;p&gt;Rust does not say:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Low-level programming is forbidden."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Instead, Rust says:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Dangerous operations should be explicit and isolated.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;A well-designed Rust program might look conceptually like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;┌──────────────────────────────┐
│          Safe Rust           │
│                              │
│ Application logic            │
│ Data structures              │
│ Algorithms                   │
│ Business logic               │
│                              │
└───────────────┬──────────────┘
                │
                │ Explicit boundary
                ▼
┌──────────────────────────────┐
│         Unsafe Rust          │
│                              │
│ Raw pointers                 │
│ Memory manipulation          │
│ Hardware access              │
│ OS interfaces                │
│ C interoperability           │
│                              │
└──────────────────────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The goal is to keep the unsafe boundary small.&lt;/p&gt;

&lt;p&gt;If a small, carefully reviewed section of code performs dangerous operations correctly, the rest of the program can benefit from stronger safety guarantees.&lt;/p&gt;




&lt;h2&gt;
  
  
  9. Fearless Concurrency
&lt;/h2&gt;

&lt;p&gt;Concurrency is one of the hardest parts of systems programming.&lt;/p&gt;

&lt;p&gt;When multiple threads access shared memory, programmers must carefully control:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Ownership&lt;/li&gt;
&lt;li&gt;Mutability&lt;/li&gt;
&lt;li&gt;Synchronization&lt;/li&gt;
&lt;li&gt;Lifetime&lt;/li&gt;
&lt;li&gt;Shared access&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A mistake can result in a data race or unpredictable behavior.&lt;/p&gt;

&lt;p&gt;Rust's type system helps enforce important rules about how data can be transferred and shared between threads.&lt;/p&gt;

&lt;p&gt;Two important traits are:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="nb"&gt;Send&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="nb"&gt;Sync&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In simplified terms:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;Send&lt;/code&gt; means a type can safely be transferred between threads.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Sync&lt;/code&gt; means a type can safely be shared between threads under Rust's rules.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Rust cannot eliminate every concurrency bug. Deadlocks and incorrect algorithms are still possible.&lt;/p&gt;

&lt;p&gt;However, Rust can prevent many unsafe memory access patterns at compile time.&lt;/p&gt;

&lt;p&gt;This is why Rust is often associated with the phrase:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Fearless concurrency.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The idea is not that concurrency becomes easy.&lt;/p&gt;

&lt;p&gt;The idea is that programmers can build concurrent systems while the compiler checks many important safety constraints.&lt;/p&gt;




&lt;h2&gt;
  
  
  10. The Compiler Is More Than a Translator
&lt;/h2&gt;

&lt;p&gt;In C, a compiler is often thought of primarily as something that transforms source code into machine code.&lt;/p&gt;

&lt;p&gt;Rust's compiler also acts as a correctness tool.&lt;/p&gt;

&lt;p&gt;A Rust compiler error might indicate that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Ownership is unclear&lt;/li&gt;
&lt;li&gt;A reference might outlive the data it references&lt;/li&gt;
&lt;li&gt;Multiple parts of the program have conflicting access&lt;/li&gt;
&lt;li&gt;A value has been moved&lt;/li&gt;
&lt;li&gt;A potentially invalid operation exists&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;At first, this can feel frustrating.&lt;/p&gt;

&lt;p&gt;You may write code that makes perfect sense to you and receive several compiler errors.&lt;/p&gt;

&lt;p&gt;But over time, the Rust mindset changes.&lt;/p&gt;

&lt;p&gt;Instead of thinking:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"The compiler is stopping me from writing my program."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;You begin thinking:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"The compiler found a problem in my assumptions about the program."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Rust pushes some debugging work earlier in the development process.&lt;/p&gt;

&lt;p&gt;Instead of:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Write code
    ↓
Compile
    ↓
Run
    ↓
Crash
    ↓
Debug
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Rust tries to move more problems here:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Design
    ↓
Write code
    ↓
Compiler checks rules and invariants
    ↓
Fix design problems
    ↓
Run
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This does not mean Rust programs cannot contain bugs.&lt;/p&gt;

&lt;p&gt;They absolutely can.&lt;/p&gt;

&lt;p&gt;But Rust attempts to eliminate entire categories of memory-related bugs before the program executes.&lt;/p&gt;




&lt;h2&gt;
  
  
  11. Performance and Correctness Are Not Opposites
&lt;/h2&gt;

&lt;p&gt;Historically, programmers sometimes had to choose between:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;High-level language
        ↓
More convenience
Less control
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Low-level language
        ↓
More control
More responsibility
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Rust attempts to challenge this tradeoff.&lt;/p&gt;

&lt;p&gt;Rust wants:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;High Performance
       +
Memory Safety
       +
Modern Abstractions
       +
Low-Level Control
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is the core reason Rust is interesting for systems programming.&lt;/p&gt;

&lt;p&gt;You can work with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Filesystems&lt;/li&gt;
&lt;li&gt;Databases&lt;/li&gt;
&lt;li&gt;Networking&lt;/li&gt;
&lt;li&gt;Embedded systems&lt;/li&gt;
&lt;li&gt;Operating systems&lt;/li&gt;
&lt;li&gt;Compilers&lt;/li&gt;
&lt;li&gt;Game engines&lt;/li&gt;
&lt;li&gt;Command-line tools&lt;/li&gt;
&lt;li&gt;High-performance servers&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;while still using a language designed to catch many common mistakes.&lt;/p&gt;




&lt;h1&gt;
  
  
  Rust vs C: A Philosophical Comparison
&lt;/h1&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Topic&lt;/th&gt;
&lt;th&gt;C&lt;/th&gt;
&lt;th&gt;Rust&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Memory management&lt;/td&gt;
&lt;td&gt;Manual&lt;/td&gt;
&lt;td&gt;Ownership-based&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Memory safety&lt;/td&gt;
&lt;td&gt;Programmer responsibility&lt;/td&gt;
&lt;td&gt;Compiler-enforced in safe code&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Null values&lt;/td&gt;
&lt;td&gt;Pointers can be &lt;code&gt;NULL&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;Option&amp;lt;T&amp;gt;&lt;/code&gt; models absence&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Error handling&lt;/td&gt;
&lt;td&gt;Error codes and conventions&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Result&amp;lt;T, E&amp;gt;&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Ownership&lt;/td&gt;
&lt;td&gt;Documentation and discipline&lt;/td&gt;
&lt;td&gt;Language-level rules&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Concurrency&lt;/td&gt;
&lt;td&gt;Programmer manages safety&lt;/td&gt;
&lt;td&gt;Type system checks important constraints&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Abstraction&lt;/td&gt;
&lt;td&gt;Often manually implemented&lt;/td&gt;
&lt;td&gt;Modern zero-cost abstractions&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Dangerous operations&lt;/td&gt;
&lt;td&gt;Can appear throughout code&lt;/td&gt;
&lt;td&gt;Explicit &lt;code&gt;unsafe&lt;/code&gt; boundaries&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Performance&lt;/td&gt;
&lt;td&gt;Direct and predictable control&lt;/td&gt;
&lt;td&gt;Systems-level performance with abstractions&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;C gives the programmer enormous freedom.&lt;/p&gt;

&lt;p&gt;Rust asks the programmer to follow stricter rules in exchange for stronger guarantees.&lt;/p&gt;




&lt;h1&gt;
  
  
  The Biggest Mindset Change for C Programmers
&lt;/h1&gt;

&lt;p&gt;If you come from C, your first questions might be:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Where is this allocated?

Who calls malloc?

Who calls free?

What pointer points to this memory?

Can I modify these bytes directly?
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In Rust, you often start with different questions:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Who owns this data?

Who needs temporary access?

Can multiple parts modify it?

How long should this reference live?

Should ownership move?

Can this invalid state exist?
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is the fundamental mental shift.&lt;/p&gt;

&lt;p&gt;Rust does not remove low-level programming.&lt;/p&gt;

&lt;p&gt;You can still work with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Memory layouts&lt;/li&gt;
&lt;li&gt;Raw pointers&lt;/li&gt;
&lt;li&gt;System calls&lt;/li&gt;
&lt;li&gt;File descriptors&lt;/li&gt;
&lt;li&gt;Hardware&lt;/li&gt;
&lt;li&gt;Binary data&lt;/li&gt;
&lt;li&gt;FFI&lt;/li&gt;
&lt;li&gt;Allocators&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But Rust asks you to make the safety boundaries explicit.&lt;/p&gt;




&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;The philosophy of Rust can be summarized in one sentence:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Use the type system and compiler to enforce as many important correctness guarantees as possible before the program runs.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Rust is built on several major ideas:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Memory safety without garbage collection&lt;/li&gt;
&lt;li&gt;Clear ownership of resources&lt;/li&gt;
&lt;li&gt;Controlled access through borrowing&lt;/li&gt;
&lt;li&gt;Explicit representation of absence and failure&lt;/li&gt;
&lt;li&gt;Strong type-driven design&lt;/li&gt;
&lt;li&gt;Zero-cost abstractions&lt;/li&gt;
&lt;li&gt;Concurrency with stronger safety guarantees&lt;/li&gt;
&lt;li&gt;Explicit boundaries around dangerous operations&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Rust does not assume that programmers are careless.&lt;/p&gt;

&lt;p&gt;Instead, it recognizes that even experienced programmers make mistakes, especially when building large, complex, concurrent systems.&lt;/p&gt;

&lt;p&gt;Its answer is not to remove control from the programmer.&lt;/p&gt;

&lt;p&gt;Its answer is to combine &lt;strong&gt;control with stronger guarantees&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;For a systems programmer, Rust can be understood like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;C:
Maximum freedom
        +
Maximum responsibility
        +
Potential undefined behavior
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Low-level control
        +
Strong compiler guarantees
        +
Explicit unsafe boundaries
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Rust's syntax is not the hardest thing to learn.&lt;/p&gt;

&lt;p&gt;The real challenge is learning to think in terms of &lt;strong&gt;ownership, borrowing, lifetimes, and types as tools for designing correct systems&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Once that mindset becomes natural, Rust stops feeling like a restrictive language.&lt;/p&gt;

&lt;p&gt;It starts feeling like a language that helps you build complex software with a different kind of confidence.&lt;/p&gt;

</description>
      <category>rust</category>
      <category>systems</category>
      <category>productivity</category>
      <category>farhadrahimiklie</category>
    </item>
    <item>
      <title>Terminal: The Interface That Makes You Understand Your Computer</title>
      <dc:creator>Farhad Rahimi Klie</dc:creator>
      <pubDate>Mon, 24 Aug 2026 03:46:47 +0000</pubDate>
      <link>https://dev.to/farhadrahimiklie/terminal-the-interface-that-makes-you-understand-your-computer-koj</link>
      <guid>https://dev.to/farhadrahimiklie/terminal-the-interface-that-makes-you-understand-your-computer-koj</guid>
      <description>&lt;p&gt;Most developers start their programming journey with a graphical interface: an IDE, buttons, menus, file explorers, and colorful dashboards.&lt;/p&gt;

&lt;p&gt;Then, sooner or later, they encounter something that looks much more intimidating:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;strong&gt;Terminal&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;For beginners, the terminal can feel old, difficult, and unnecessary. Why type commands when you can click buttons?&lt;/p&gt;

&lt;p&gt;But as you become a developer, you begin to realize something important:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The terminal is not an outdated way of using a computer. It is one of the most direct ways to communicate with it.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In this article, we'll explore what the terminal is, why developers use it, how it works, and why learning it can fundamentally change the way you understand software.&lt;/p&gt;




&lt;h1&gt;
  
  
  What Is a Terminal?
&lt;/h1&gt;

&lt;p&gt;A &lt;strong&gt;terminal&lt;/strong&gt; is a text-based interface that allows you to interact with your operating system by typing commands.&lt;/p&gt;

&lt;p&gt;Instead of this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Open File Explorer
↓
Click a folder
↓
Find a file
↓
Right-click
↓
Choose an action
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can do 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;cd &lt;/span&gt;projects
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;mkdir &lt;/span&gt;my_project
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;or:&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;rm &lt;/span&gt;old_file.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The terminal accepts your commands, sends them to the operating system, and displays the result.&lt;/p&gt;

&lt;p&gt;A simplified model looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;You
 │
 │ Type command
 ▼
┌─────────────┐
│  Terminal   │
└──────┬──────┘
       │
       ▼
┌─────────────┐
│    Shell    │
└──────┬──────┘
       │
       ▼
┌─────────────┐
│ Operating   │
│   System    │
└─────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There are actually several different components involved.&lt;/p&gt;




&lt;h1&gt;
  
  
  Terminal vs Shell vs Command Line
&lt;/h1&gt;

&lt;p&gt;These terms are often used interchangeably, but they are not exactly the same.&lt;/p&gt;

&lt;h2&gt;
  
  
  Terminal
&lt;/h2&gt;

&lt;p&gt;The terminal is the application or environment where you type commands.&lt;/p&gt;

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

&lt;ul&gt;
&lt;li&gt;Windows Terminal&lt;/li&gt;
&lt;li&gt;GNOME Terminal&lt;/li&gt;
&lt;li&gt;iTerm&lt;/li&gt;
&lt;li&gt;Alacritty&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The terminal provides the interface.&lt;/p&gt;




&lt;h2&gt;
  
  
  Shell
&lt;/h2&gt;

&lt;p&gt;The &lt;strong&gt;shell&lt;/strong&gt; is the program that reads and interprets your commands.&lt;/p&gt;

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

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

&lt;/div&gt;



&lt;p&gt;The shell reads that command and decides what program or operation should be executed.&lt;/p&gt;

&lt;p&gt;Popular shells include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Bash&lt;/li&gt;
&lt;li&gt;Zsh&lt;/li&gt;
&lt;li&gt;Fish&lt;/li&gt;
&lt;li&gt;PowerShell&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The relationship looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;┌──────────────────┐
│     Terminal     │
│                  │
│   You type here  │
└────────┬─────────┘
         │
         ▼
┌──────────────────┐
│      Shell       │
│                  │
│ Interprets input │
└────────┬─────────┘
         │
         ▼
┌──────────────────┐
│ Operating System │
└──────────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So technically:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The terminal displays the interface. The shell interprets your commands.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h1&gt;
  
  
  Your First Terminal Commands
&lt;/h1&gt;

&lt;p&gt;Let's imagine you are using Linux or macOS.&lt;/p&gt;

&lt;p&gt;When you open a terminal, you might see something like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;farhad@computer:~&lt;span class="err"&gt;$&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is called the &lt;strong&gt;prompt&lt;/strong&gt;.&lt;/p&gt;

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

&lt;blockquote&gt;
&lt;p&gt;The shell is ready and waiting for your command.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Let's try a few commands.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where Am I?
&lt;/h2&gt;



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

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;pwd&lt;/code&gt; means:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Print Working Directory
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/home/farhad
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Your &lt;strong&gt;working directory&lt;/strong&gt; is simply the folder you are currently inside.&lt;/p&gt;




&lt;h2&gt;
  
  
  List Files
&lt;/h2&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;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;Documents
Downloads
Projects
Pictures
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command asks the operating system:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Show me the files and directories here.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;You can also use:&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;span class="nt"&gt;-l&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Which provides more information:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;drwxr-xr-x Projects
-rw-r--r-- notes.txt
-rwxr-xr-x program
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you are not just seeing file names. You are seeing information about files.&lt;/p&gt;




&lt;h1&gt;
  
  
  Moving Through the Filesystem
&lt;/h1&gt;

&lt;p&gt;Suppose your computer contains:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;home
└── farhad
    ├── Documents
    ├── Downloads
    └── Projects
        └── database
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you are currently here:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/home/farhad
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can enter the &lt;code&gt;Projects&lt;/code&gt; directory:&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;cd &lt;/span&gt;Projects
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now:&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;pwd&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;might return:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/home/farhad/Projects
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then:&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;cd &lt;/span&gt;database
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you are here:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/home
└── farhad
    └── Projects
        └── database ← You are here
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To go back one directory:&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;cd&lt;/span&gt; ..
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;..&lt;/code&gt; means:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Parent directory.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;To go directly to your home directory:&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;cd&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These commands may seem simple, but they introduce one of the most important concepts in computing:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Everything has a location.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h1&gt;
  
  
  Creating Files and Directories
&lt;/h1&gt;

&lt;p&gt;Create a directory:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;mkdir &lt;/span&gt;my_project
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;current_directory
└── my_project
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Move into it:&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;cd &lt;/span&gt;my_project
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create a file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;touch &lt;/span&gt;main.c
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;my_project
└── main.c
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You just created a project structure without opening a graphical file manager.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;mkdir &lt;/span&gt;database
&lt;span class="nb"&gt;cd &lt;/span&gt;database

&lt;span class="nb"&gt;mkdir &lt;/span&gt;src
&lt;span class="nb"&gt;mkdir &lt;/span&gt;include
&lt;span class="nb"&gt;mkdir &lt;/span&gt;tests

&lt;span class="nb"&gt;touch &lt;/span&gt;src/main.c
&lt;span class="nb"&gt;touch &lt;/span&gt;include/database.h
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The result:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;database
├── src
│   └── main.c
│
├── include
│   └── database.h
│
└── tests
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is one reason developers love the terminal.&lt;/p&gt;

&lt;p&gt;You can describe a sequence of actions precisely.&lt;/p&gt;




&lt;h1&gt;
  
  
  The Terminal Is Built Around Programs
&lt;/h1&gt;

&lt;p&gt;One important thing to understand is this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ls
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;is not magic.&lt;/p&gt;

&lt;p&gt;Usually, when you type a command, the shell searches for a program with that name and executes it.&lt;/p&gt;

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

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

&lt;/div&gt;



&lt;p&gt;starts the C compiler.&lt;/p&gt;

&lt;p&gt;You might write:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;gcc main.c &lt;span class="nt"&gt;-o&lt;/span&gt; app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;You
 │
 │ gcc main.c -o app
 ▼
Shell
 │
 │ Find gcc
 ▼
C Compiler
 │
 │ Compile main.c
 ▼
app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then you can run your program:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;./app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The terminal becomes the place where your entire development workflow happens.&lt;/p&gt;




&lt;h1&gt;
  
  
  Why Developers Prefer the Terminal
&lt;/h1&gt;

&lt;p&gt;The biggest advantage is not that the terminal looks cool.&lt;/p&gt;

&lt;p&gt;The real advantage is &lt;strong&gt;control&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;With a GUI, you often perform actions manually.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Click
↓
Click
↓
Select
↓
Right-click
↓
Choose option
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With the terminal:&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;command &lt;/span&gt;argument option
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A command can be repeated exactly.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;gcc main.c &lt;span class="nt"&gt;-o&lt;/span&gt; program
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can run the same command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;gcc main.c &lt;span class="nt"&gt;-o&lt;/span&gt; program
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Again.&lt;/p&gt;

&lt;p&gt;And again.&lt;/p&gt;

&lt;p&gt;The instructions do not change.&lt;/p&gt;

&lt;p&gt;This makes the terminal extremely useful for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Programming&lt;/li&gt;
&lt;li&gt;Building software&lt;/li&gt;
&lt;li&gt;Managing files&lt;/li&gt;
&lt;li&gt;Running servers&lt;/li&gt;
&lt;li&gt;Compiling code&lt;/li&gt;
&lt;li&gt;Debugging&lt;/li&gt;
&lt;li&gt;Automation&lt;/li&gt;
&lt;li&gt;Git&lt;/li&gt;
&lt;li&gt;Docker&lt;/li&gt;
&lt;li&gt;Databases&lt;/li&gt;
&lt;li&gt;System administration&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  Commands Can Be Combined
&lt;/h1&gt;

&lt;p&gt;This is where the terminal becomes especially powerful.&lt;/p&gt;

&lt;p&gt;Suppose you want to see all files ending in &lt;code&gt;.c&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;You can use:&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;p&gt;But you can also combine commands and filters.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;ls&lt;/span&gt; | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="s2"&gt;".c"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;|&lt;/code&gt; symbol is called a &lt;strong&gt;pipe&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;It connects programs together.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;┌──────┐
│  ls  │
└───┬──┘
    │
    │ Output
    ▼
┌────────┐
│  grep  │
└───┬────┘
    │
    ▼
 Result
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is one of the core ideas behind Unix-like systems:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Small programs can be combined to perform larger tasks.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Instead of building one giant program that does everything:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;GIANT_PROGRAM
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Unix philosophy encourages:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Small Tool
     │
     ▼
Small Tool
     │
     ▼
Small Tool
     │
     ▼
Result
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The terminal makes this composition natural.&lt;/p&gt;




&lt;h1&gt;
  
  
  Input, Output, and Redirection
&lt;/h1&gt;

&lt;p&gt;Programs usually have three important streams:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Standard Input
Standard Output
Standard Error
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can think of them like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Keyboard
   │
   ▼
stdin
   │
┌──────────┐
│ Program  │
└────┬─────┘
     │
     ├──── stdout ────► Screen
     │
     └──── stderr ────► Error Message
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The terminal allows you to redirect these streams.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Hello"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; output.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Normally:&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;echo&lt;/span&gt; &lt;span class="s2"&gt;"Hello"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Hello
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But 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;echo&lt;/span&gt; &lt;span class="s2"&gt;"Hello"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; output.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;sends the output into a file.&lt;/p&gt;

&lt;p&gt;The result:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;output.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Hello
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also append:&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;echo&lt;/span&gt; &lt;span class="s2"&gt;"Another line"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; output.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This simple concept is the foundation of many automation workflows.&lt;/p&gt;




&lt;h1&gt;
  
  
  The Terminal and Programming
&lt;/h1&gt;

&lt;p&gt;If you are a C programmer, the terminal becomes especially important.&lt;/p&gt;

&lt;p&gt;Imagine you have:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;project
└── main.c
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You compile it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;gcc main.c &lt;span class="nt"&gt;-o&lt;/span&gt; program
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;project
├── main.c
└── program
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;./program
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you modify your source code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;main.c
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You compile again:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;gcc main.c &lt;span class="nt"&gt;-o&lt;/span&gt; program
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;./program
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This gives you a direct understanding of the software pipeline:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Source Code
     │
     ▼
┌───────────┐
│ Compiler  │
└─────┬─────┘
      ▼
Machine Code
      │
      ▼
Executable
      │
      ▼
Operating System
      │
      ▼
Running Program
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;An IDE can hide this process behind a button called:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Run
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But the terminal forces you to see what is actually happening.&lt;/p&gt;

&lt;p&gt;That is valuable when you want to understand systems programming.&lt;/p&gt;




&lt;h1&gt;
  
  
  The Terminal Is Excellent for Automation
&lt;/h1&gt;

&lt;p&gt;Imagine you have 1,000 files.&lt;/p&gt;

&lt;p&gt;You want to perform the same operation on every file.&lt;/p&gt;

&lt;p&gt;Doing this manually would be painful.&lt;/p&gt;

&lt;p&gt;But with scripting:&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="k"&gt;for &lt;/span&gt;file &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="k"&gt;*&lt;/span&gt;.txt
&lt;span class="k"&gt;do
    &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$file&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can automate repetitive work.&lt;/p&gt;

&lt;p&gt;A simple script might:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Compile your program.&lt;/li&gt;
&lt;li&gt;Run tests.&lt;/li&gt;
&lt;li&gt;Create a backup.&lt;/li&gt;
&lt;li&gt;Generate logs.&lt;/li&gt;
&lt;li&gt;Deploy your application.&lt;/li&gt;
&lt;/ol&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/bin/bash&lt;/span&gt;

gcc main.c &lt;span class="nt"&gt;-o&lt;/span&gt; app

./app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Instead of manually typing multiple commands, you can execute:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;./build.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is why terminals are closely connected to:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Automation
+
Programming
+
Reproducibility
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h1&gt;
  
  
  The Terminal and Git
&lt;/h1&gt;

&lt;p&gt;Modern software development would be difficult without version control.&lt;/p&gt;

&lt;p&gt;A typical Git workflow looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git status
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;See what changed.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git add &lt;span class="nb"&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Stage changes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git commit &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"Add database page implementation"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create a commit.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git push
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Send your changes to a remote repository.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Your Files
    │
    ▼
git add
    │
    ▼
Staging Area
    │
    ▼
git commit
    │
    ▼
Local Repository
    │
    ▼
git push
    │
    ▼
Remote Repository
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The terminal gives you direct access to these tools.&lt;/p&gt;




&lt;h1&gt;
  
  
  The Terminal Is Not Just for Linux
&lt;/h1&gt;

&lt;p&gt;Many people associate terminals with Linux.&lt;/p&gt;

&lt;p&gt;But command-line environments exist everywhere.&lt;/p&gt;

&lt;h2&gt;
  
  
  Linux
&lt;/h2&gt;

&lt;p&gt;Common shell:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Bash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Zsh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  macOS
&lt;/h2&gt;

&lt;p&gt;Common shells include:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Zsh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and Bash.&lt;/p&gt;

&lt;h2&gt;
  
  
  Windows
&lt;/h2&gt;

&lt;p&gt;You can use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Command Prompt
PowerShell
Windows Terminal
WSL
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With WSL, Windows users can run a Linux environment directly alongside Windows.&lt;/p&gt;

&lt;p&gt;The important thing is not the specific terminal application.&lt;/p&gt;

&lt;p&gt;The important skill is learning how to think in commands.&lt;/p&gt;




&lt;h1&gt;
  
  
  The Terminal Changes How You Think
&lt;/h1&gt;

&lt;p&gt;This is the part beginners often don't realize.&lt;/p&gt;

&lt;p&gt;A graphical interface usually asks:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Where is the button?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The terminal asks:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;What operation do I want to perform?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;For example, instead of thinking:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Where is the button to create a directory?
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You think:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;I want to create a directory.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;mkdir &lt;/span&gt;project
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is a more direct relationship between your intention and the operation.&lt;/p&gt;

&lt;p&gt;The terminal encourages you to think in:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Input
↓
Process
↓
Output
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That same model appears everywhere in programming.&lt;/p&gt;




&lt;h1&gt;
  
  
  A Practical Developer Workflow
&lt;/h1&gt;

&lt;p&gt;Imagine starting a new C project.&lt;/p&gt;

&lt;p&gt;You might do:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;mkdir &lt;/span&gt;my_database
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then:&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;cd &lt;/span&gt;my_database
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create directories:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;mkdir &lt;/span&gt;src
&lt;span class="nb"&gt;mkdir &lt;/span&gt;include
&lt;span class="nb"&gt;mkdir &lt;/span&gt;build
&lt;span class="nb"&gt;mkdir &lt;/span&gt;tests
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create files:&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;touch &lt;/span&gt;src/main.c
&lt;span class="nb"&gt;touch &lt;/span&gt;include/database.h
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;gcc src/main.c &lt;span class="nt"&gt;-Iinclude&lt;/span&gt; &lt;span class="nt"&gt;-o&lt;/span&gt; build/database
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;./build/database
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Check Git:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git status
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git add &lt;span class="nb"&gt;.&lt;/span&gt;
git commit &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"Create initial project structure"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In just a few commands, you have:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;my_database
│
├── src
│   └── main.c
│
├── include
│   └── database.h
│
├── build
│   └── database
│
└── tests
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The terminal becomes your development control center.&lt;/p&gt;




&lt;h1&gt;
  
  
  Is the Terminal Difficult?
&lt;/h1&gt;

&lt;p&gt;At first, yes.&lt;/p&gt;

&lt;p&gt;You need to remember commands.&lt;/p&gt;

&lt;p&gt;You need to understand paths.&lt;/p&gt;

&lt;p&gt;You need to understand files and permissions.&lt;/p&gt;

&lt;p&gt;You will make mistakes.&lt;/p&gt;

&lt;p&gt;But you do not need to memorize hundreds of commands.&lt;/p&gt;

&lt;p&gt;Start with these:&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;pwd
ls
cd
mkdir
touch
cp
mv
rm
cat
&lt;/span&gt;clear
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then gradually learn:&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;grep
&lt;/span&gt;find
&lt;span class="nb"&gt;chmod
&lt;/span&gt;ps
&lt;span class="nb"&gt;kill
&lt;/span&gt;curl
ssh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then developer tools:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git
gcc
make
cmake
python
docker
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You learn the terminal the same way you learn programming:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;One command at a time.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h1&gt;
  
  
  The Real Power of the Terminal
&lt;/h1&gt;

&lt;p&gt;The terminal is powerful because it gives you a programmable interface to your computer.&lt;/p&gt;

&lt;p&gt;A graphical interface is usually designed around predefined actions.&lt;/p&gt;

&lt;p&gt;The terminal allows you to combine actions.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Program A
    │
    ▼
Program B
    │
    ▼
Program C
    │
    ▼
File
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can create workflows that are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Repeatable&lt;/li&gt;
&lt;li&gt;Scriptable&lt;/li&gt;
&lt;li&gt;Automatable&lt;/li&gt;
&lt;li&gt;Precise&lt;/li&gt;
&lt;li&gt;Fast&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That is why the terminal remains essential even in a world filled with advanced graphical tools.&lt;/p&gt;




&lt;h1&gt;
  
  
  Final Thoughts
&lt;/h1&gt;

&lt;p&gt;The terminal might look simple:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But behind that small prompt is access to an enormous ecosystem of programs and system capabilities.&lt;/p&gt;

&lt;p&gt;You can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Navigate your filesystem.&lt;/li&gt;
&lt;li&gt;Create and manage projects.&lt;/li&gt;
&lt;li&gt;Compile programs.&lt;/li&gt;
&lt;li&gt;Run applications.&lt;/li&gt;
&lt;li&gt;Debug software.&lt;/li&gt;
&lt;li&gt;Control Git repositories.&lt;/li&gt;
&lt;li&gt;Connect to remote servers.&lt;/li&gt;
&lt;li&gt;Automate repetitive tasks.&lt;/li&gt;
&lt;li&gt;Build complete development pipelines.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The terminal is not something you need to master in one week.&lt;/p&gt;

&lt;p&gt;Start small.&lt;/p&gt;

&lt;p&gt;Learn how to move:&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;cd&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Learn how to inspect:&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;p&gt;Learn how to create:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Then slowly connect those commands together.&lt;/p&gt;

&lt;p&gt;Eventually, you may stop seeing the terminal as a black screen with confusing text.&lt;/p&gt;

&lt;p&gt;You will see it for what it really is:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;A direct interface between your ideas, your programs, and your computer.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;And once you become comfortable with it, the terminal stops feeling like an obstacle.&lt;/p&gt;

&lt;p&gt;It becomes one of the most powerful tools in your development workflow.&lt;/p&gt;

</description>
      <category>terminal</category>
      <category>cli</category>
      <category>productivity</category>
      <category>farhadrahimiklie</category>
    </item>
    <item>
      <title>Linus Torvalds: The Programmer Who Changed the World With Linux and Git</title>
      <dc:creator>Farhad Rahimi Klie</dc:creator>
      <pubDate>Wed, 19 Aug 2026 01:52:52 +0000</pubDate>
      <link>https://dev.to/farhadrahimiklie/linus-torvalds-the-programmer-who-changed-the-world-with-linux-and-git-bha</link>
      <guid>https://dev.to/farhadrahimiklie/linus-torvalds-the-programmer-who-changed-the-world-with-linux-and-git-bha</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;From a personal computer project to Linux, Git, and the foundations of modern computing.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;When we talk about the people who shaped modern software development, one name stands out: &lt;strong&gt;Linus Torvalds&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;He is best known as the creator of the &lt;strong&gt;Linux kernel&lt;/strong&gt;, the core software that powers Linux operating systems and countless servers, smartphones, embedded devices, cloud systems, and supercomputers.&lt;/p&gt;

&lt;p&gt;But Torvalds created something else that programmers use every day: &lt;strong&gt;Git&lt;/strong&gt;, the distributed version-control system.&lt;/p&gt;

&lt;p&gt;His story is interesting because it demonstrates an important lesson in software engineering:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;You don't always need to begin with a giant plan. Sometimes, a small technical project can grow into something much bigger than you imagined.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Who Is Linus Torvalds?
&lt;/h2&gt;

&lt;p&gt;Linus Torvalds is a Finnish-American software engineer and programmer, born on &lt;strong&gt;December 28, 1969, in Helsinki, Finland&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;He became interested in computers at a young age and eventually studied computer science at the &lt;strong&gt;University of Helsinki&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;In the early 1990s, personal computers were becoming increasingly popular, but the operating systems and development environments available to students were limited.&lt;/p&gt;

&lt;p&gt;Torvalds was interested in operating-system technology and began experimenting with a computer running &lt;strong&gt;MINIX&lt;/strong&gt;, an operating system created by Andrew S. Tanenbaum for educational purposes.&lt;/p&gt;

&lt;p&gt;That experimentation eventually led to Linux.&lt;/p&gt;




&lt;h1&gt;
  
  
  The Beginning of Linux
&lt;/h1&gt;

&lt;p&gt;In 1991, Torvalds started developing an operating-system kernel as a personal project.&lt;/p&gt;

&lt;p&gt;At first, Linux was not intended to become the foundation of a massive global ecosystem.&lt;/p&gt;

&lt;p&gt;It was simply a project for learning and experimentation.&lt;/p&gt;

&lt;p&gt;The original announcement was famously modest. Torvalds described what he was working on and invited other people to try it.&lt;/p&gt;

&lt;p&gt;That small project eventually became the &lt;strong&gt;Linux kernel&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The important distinction is:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Linux is technically a kernel, not a complete operating system by itself.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The kernel manages fundamental resources such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;CPU scheduling&lt;/li&gt;
&lt;li&gt;Memory&lt;/li&gt;
&lt;li&gt;Processes&lt;/li&gt;
&lt;li&gt;Devices&lt;/li&gt;
&lt;li&gt;Filesystems&lt;/li&gt;
&lt;li&gt;Networking&lt;/li&gt;
&lt;li&gt;System calls&lt;/li&gt;
&lt;li&gt;Hardware interaction&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A complete Linux-based operating system combines the kernel with many other components.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Linux-based operating system
│
├── Linux Kernel
│   ├── CPU management
│   ├── Memory management
│   ├── Process management
│   ├── Networking
│   ├── Device drivers
│   └── Filesystems
│
├── System libraries
├── Shell
├── Utilities
├── Desktop environment
└── Applications
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This architecture is one reason Linux became extremely flexible.&lt;/p&gt;




&lt;h1&gt;
  
  
  Why Was Linux Important?
&lt;/h1&gt;

&lt;p&gt;Linux was released as an open-source project.&lt;/p&gt;

&lt;p&gt;That meant programmers around the world could study the source code, modify it, improve it, and contribute changes.&lt;/p&gt;

&lt;p&gt;This created a powerful development model.&lt;/p&gt;

&lt;p&gt;Instead of one company controlling the entire operating system, thousands of developers and organizations could participate.&lt;/p&gt;

&lt;p&gt;Over time, Linux became important in many areas of computing.&lt;/p&gt;

&lt;p&gt;Today, Linux is widely used in:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Web servers&lt;/li&gt;
&lt;li&gt;Cloud infrastructure&lt;/li&gt;
&lt;li&gt;Supercomputers&lt;/li&gt;
&lt;li&gt;Embedded systems&lt;/li&gt;
&lt;li&gt;Networking equipment&lt;/li&gt;
&lt;li&gt;Development environments&lt;/li&gt;
&lt;li&gt;Containers&lt;/li&gt;
&lt;li&gt;Android's kernel foundation&lt;/li&gt;
&lt;li&gt;Routers&lt;/li&gt;
&lt;li&gt;Internet infrastructure&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A huge amount of modern computing infrastructure depends on Linux.&lt;/p&gt;




&lt;h1&gt;
  
  
  The Linux Development Model
&lt;/h1&gt;

&lt;p&gt;One of the most interesting parts of Torvalds' work isn't simply the code.&lt;/p&gt;

&lt;p&gt;It is the &lt;strong&gt;development process&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The Linux kernel is developed collaboratively by a large global community.&lt;/p&gt;

&lt;p&gt;A simplified version of the process looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Developer
   │
   ▼
Writes a change
   │
   ▼
Creates a patch
   │
   ▼
Patch is reviewed
   │
   ▼
Maintainer reviews it
   │
   ▼
Changes move through subsystem maintainers
   │
   ▼
Linux kernel integration
   │
   ▼
Testing
   │
   ▼
Release
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This model allows thousands of contributors to work on an enormous codebase while maintaining a structured hierarchy of review and maintenance.&lt;/p&gt;




&lt;h1&gt;
  
  
  What Is the Linux Kernel Actually Doing?
&lt;/h1&gt;

&lt;p&gt;Imagine you write this C program:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="cp"&gt;#include&lt;/span&gt; &lt;span class="cpf"&gt;&amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;span class="cp"&gt;
&lt;/span&gt;
&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;void&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Hello, world!&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Your program doesn't directly control the hardware.&lt;/p&gt;

&lt;p&gt;There are layers between your application and the physical machine.&lt;/p&gt;

&lt;p&gt;A simplified model looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Your C Program
      │
      ▼
C Library
      │
      ▼
System Calls
      │
      ▼
Linux Kernel
      │
      ▼
Hardware
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For example, when a program needs to read a file, it eventually asks the operating system to perform that operation.&lt;/p&gt;

&lt;p&gt;The kernel handles the interaction with the storage device.&lt;/p&gt;

&lt;p&gt;This is one of the fundamental responsibilities of an operating-system kernel:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;providing controlled access to hardware and system resources.&lt;/strong&gt;&lt;/p&gt;




&lt;h1&gt;
  
  
  Linux and C
&lt;/h1&gt;

&lt;p&gt;If you're learning C and interested in operating systems, Linux is particularly important.&lt;/p&gt;

&lt;p&gt;Much of the Linux kernel is written in C, along with some architecture-specific assembly code.&lt;/p&gt;

&lt;p&gt;This makes Linux an excellent real-world example for understanding systems programming.&lt;/p&gt;

&lt;p&gt;You can encounter concepts such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Pointers&lt;/li&gt;
&lt;li&gt;Structures&lt;/li&gt;
&lt;li&gt;Memory management&lt;/li&gt;
&lt;li&gt;Processes&lt;/li&gt;
&lt;li&gt;Threads&lt;/li&gt;
&lt;li&gt;Interrupts&lt;/li&gt;
&lt;li&gt;System calls&lt;/li&gt;
&lt;li&gt;File descriptors&lt;/li&gt;
&lt;li&gt;Virtual memory&lt;/li&gt;
&lt;li&gt;Scheduling&lt;/li&gt;
&lt;li&gt;Device drivers&lt;/li&gt;
&lt;li&gt;Networking&lt;/li&gt;
&lt;li&gt;Synchronization&lt;/li&gt;
&lt;li&gt;Concurrency&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For someone who wants to understand how computers work underneath high-level applications, studying Linux can be extremely valuable.&lt;/p&gt;




&lt;h1&gt;
  
  
  Torvalds Didn't Stop at Linux
&lt;/h1&gt;

&lt;p&gt;Linux is the project most people associate with Linus Torvalds.&lt;/p&gt;

&lt;p&gt;But he also created another extremely important piece of software:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Git.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Git is a distributed version-control system.&lt;/p&gt;

&lt;p&gt;It was created in 2005 during a difficult period in Linux kernel development.&lt;/p&gt;

&lt;p&gt;The Linux kernel project needed a powerful way to manage contributions from many developers.&lt;/p&gt;

&lt;p&gt;Torvalds decided to build a new version-control system.&lt;/p&gt;

&lt;p&gt;That system became Git.&lt;/p&gt;




&lt;h1&gt;
  
  
  What Is Git?
&lt;/h1&gt;

&lt;p&gt;Suppose you are developing a project.&lt;/p&gt;

&lt;p&gt;You might have:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;project/
├── main.c
├── database.c
├── database.h
└── README.md
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You make changes today.&lt;/p&gt;

&lt;p&gt;Tomorrow, you change something else.&lt;/p&gt;

&lt;p&gt;Then you realize:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"The project worked yesterday. What did I change?"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Without version control, this can become painful.&lt;/p&gt;

&lt;p&gt;Git solves this problem by recording the history of your project.&lt;/p&gt;

&lt;p&gt;A simplified Git workflow looks like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Working Directory
       │
       ▼
     git add
       │
       ▼
   Staging Area
       │
       ▼
   git commit
       │
       ▼
 Git Repository
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can then inspect previous versions of your project.&lt;/p&gt;




&lt;h1&gt;
  
  
  Why Git Became So Important
&lt;/h1&gt;

&lt;p&gt;Git has several powerful properties.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Distributed
&lt;/h2&gt;

&lt;p&gt;Every Git clone can contain the complete repository history.&lt;/p&gt;

&lt;p&gt;That means developers don't necessarily need to depend on one central server for the repository's history.&lt;/p&gt;




&lt;h2&gt;
  
  
  2. Fast
&lt;/h2&gt;

&lt;p&gt;Git was designed to handle very large development projects efficiently.&lt;/p&gt;

&lt;p&gt;This was particularly important for the Linux kernel.&lt;/p&gt;




&lt;h2&gt;
  
  
  3. Branching
&lt;/h2&gt;

&lt;p&gt;Developers can create branches for different features or experiments.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;main
 │
 ├── feature-login
 │
 ├── feature-database
 │
 └── bugfix-memory
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Different developers can work on different branches and later merge their work.&lt;/p&gt;




&lt;h2&gt;
  
  
  4. History
&lt;/h2&gt;

&lt;p&gt;Git records commits.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;A → B → C → D → E
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each commit represents a point in the project's development history.&lt;/p&gt;

&lt;p&gt;This makes it possible to understand how a project evolved.&lt;/p&gt;




&lt;h1&gt;
  
  
  GitHub and Git Are Not the Same Thing
&lt;/h1&gt;

&lt;p&gt;This distinction is important for beginners.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Git&lt;/strong&gt; is a version-control system.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;GitHub&lt;/strong&gt; is a platform that hosts Git repositories and provides collaboration features.&lt;/p&gt;

&lt;p&gt;You can use Git without GitHub.&lt;/p&gt;

&lt;p&gt;You can also use Git with other hosting platforms or your own servers.&lt;/p&gt;

&lt;p&gt;Think of it this way:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Git
│
└── Version control

GitHub
│
├── Repository hosting
├── Pull requests
├── Issues
├── Collaboration
└── Other development tools
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Git itself was created by Linus Torvalds.&lt;/p&gt;




&lt;h1&gt;
  
  
  Torvalds' Programming Philosophy
&lt;/h1&gt;

&lt;p&gt;One reason Torvalds is influential is his strong focus on practical engineering.&lt;/p&gt;

&lt;p&gt;Operating-system development requires thinking about:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Performance&lt;/li&gt;
&lt;li&gt;Memory&lt;/li&gt;
&lt;li&gt;Hardware&lt;/li&gt;
&lt;li&gt;Concurrency&lt;/li&gt;
&lt;li&gt;Reliability&lt;/li&gt;
&lt;li&gt;Compatibility&lt;/li&gt;
&lt;li&gt;Maintainability&lt;/li&gt;
&lt;li&gt;Scalability&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A small mistake in low-level software can affect an enormous number of systems.&lt;/p&gt;

&lt;p&gt;That makes kernel development very different from writing a small application.&lt;/p&gt;




&lt;h1&gt;
  
  
  Why Linux Is Difficult to Build
&lt;/h1&gt;

&lt;p&gt;If you're learning C and thinking:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"I want to build my own operating system."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Linux demonstrates just how large that problem can become.&lt;/p&gt;

&lt;p&gt;A modern operating system requires many subsystems.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Operating System
│
├── Boot process
├── Kernel
│   ├── Process management
│   ├── Memory management
│   ├── Scheduling
│   ├── System calls
│   ├── Virtual memory
│   ├── Networking
│   ├── Filesystems
│   └── Device drivers
│
├── User-space libraries
├── Shell
├── Utilities
└── Applications
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You don't need to build everything at once.&lt;/p&gt;

&lt;p&gt;A beginner can start much smaller.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Step 1 → Boot a tiny program
Step 2 → Print text
Step 3 → Handle interrupts
Step 4 → Manage memory
Step 5 → Implement processes
Step 6 → Add system calls
Step 7 → Build a filesystem
Step 8 → Add networking
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This incremental approach is much more realistic.&lt;/p&gt;




&lt;h1&gt;
  
  
  What Can We Learn From Linus Torvalds?
&lt;/h1&gt;

&lt;p&gt;There are several lessons programmers can take from his career.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Start With a Real Project
&lt;/h2&gt;

&lt;p&gt;Linux began as a personal project.&lt;/p&gt;

&lt;p&gt;You don't need to wait until you know everything before building something.&lt;/p&gt;

&lt;p&gt;Build.&lt;/p&gt;

&lt;p&gt;Then discover what you don't know.&lt;/p&gt;




&lt;h2&gt;
  
  
  2. Learn How Computers Actually Work
&lt;/h2&gt;

&lt;p&gt;If you only learn high-level programming, you can build useful applications.&lt;/p&gt;

&lt;p&gt;But learning lower-level concepts gives you a different understanding of computers.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;C
 ↓
Assembly
 ↓
CPU
 ↓
Memory
 ↓
Operating System
 ↓
System Calls
 ↓
Hardware
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You don't have to become an expert in every layer immediately.&lt;/p&gt;

&lt;p&gt;But understanding the layers is extremely useful.&lt;/p&gt;




&lt;h1&gt;
  
  
  3. Read Other People's Code
&lt;/h1&gt;

&lt;p&gt;Linux is one of the largest examples of real-world systems software.&lt;/p&gt;

&lt;p&gt;Reading mature code teaches you things tutorials often don't.&lt;/p&gt;

&lt;p&gt;You can learn:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;How large projects are organized&lt;/li&gt;
&lt;li&gt;How abstractions are designed&lt;/li&gt;
&lt;li&gt;How errors are handled&lt;/li&gt;
&lt;li&gt;How data structures are used&lt;/li&gt;
&lt;li&gt;How concurrency is implemented&lt;/li&gt;
&lt;li&gt;How performance matters&lt;/li&gt;
&lt;li&gt;How APIs evolve&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;However, don't start by trying to understand the entire Linux kernel.&lt;/p&gt;

&lt;p&gt;That's an inefficient approach.&lt;/p&gt;

&lt;p&gt;Start with smaller subsystems and concepts.&lt;/p&gt;




&lt;h1&gt;
  
  
  4. Understand Version Control
&lt;/h1&gt;

&lt;p&gt;If you are serious about programming, Git is not merely another tool to memorize.&lt;/p&gt;

&lt;p&gt;You should understand:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;repository
commit
branch
merge
rebase
remote
diff
tag
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These concepts become essential when working on real software projects.&lt;/p&gt;




&lt;h1&gt;
  
  
  5. Build Things That Are Difficult
&lt;/h1&gt;

&lt;p&gt;Torvalds' work demonstrates the value of tackling technically challenging projects.&lt;/p&gt;

&lt;p&gt;You could build smaller versions of systems such as:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Text Editor
      ↓
Shell
      ↓
Filesystem
      ↓
Database
      ↓
Network Server
      ↓
Compiler
      ↓
Operating System Kernel
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You don't need to build a production-quality version.&lt;/p&gt;

&lt;p&gt;The goal is understanding.&lt;/p&gt;

&lt;p&gt;For example, building a small database in C can teach you:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Disk layout&lt;/li&gt;
&lt;li&gt;Pages&lt;/li&gt;
&lt;li&gt;Buffer pools&lt;/li&gt;
&lt;li&gt;Indexes&lt;/li&gt;
&lt;li&gt;Serialization&lt;/li&gt;
&lt;li&gt;File I/O&lt;/li&gt;
&lt;li&gt;Memory management&lt;/li&gt;
&lt;li&gt;Concurrency&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Building a filesystem can teach you:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Blocks&lt;/li&gt;
&lt;li&gt;Inodes&lt;/li&gt;
&lt;li&gt;Directories&lt;/li&gt;
&lt;li&gt;Bitmaps&lt;/li&gt;
&lt;li&gt;Allocation&lt;/li&gt;
&lt;li&gt;Metadata&lt;/li&gt;
&lt;li&gt;File descriptors&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These projects make abstract concepts concrete.&lt;/p&gt;




&lt;h1&gt;
  
  
  Linux Is Bigger Than Linus Torvalds
&lt;/h1&gt;

&lt;p&gt;An important point is that modern Linux is &lt;strong&gt;not the work of one person&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Torvalds started the project and remains its creator and principal maintainer, but Linux has grown through contributions from a massive international community.&lt;/p&gt;

&lt;p&gt;Companies, universities, independent developers, and organizations have contributed to its development.&lt;/p&gt;

&lt;p&gt;This is one of the most impressive aspects of open-source software.&lt;/p&gt;

&lt;p&gt;A project can begin with one programmer and eventually become a global engineering effort.&lt;/p&gt;




&lt;h1&gt;
  
  
  A Simplified Timeline
&lt;/h1&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1969
 │
 └── Linus Torvalds is born
       │
1980s
 │
 └── Develops an interest in computers
       │
1991
 │
 └── Begins developing Linux
       │
1990s
 │
 └── Linux community grows
       │
2005
 │
 └── Torvalds creates Git
       │
2000s–2020s
 │
 └── Linux becomes fundamental
     infrastructure for modern computing
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h1&gt;
  
  
  The Bigger Lesson
&lt;/h1&gt;

&lt;p&gt;The most interesting part of Linus Torvalds' story isn't simply that he created Linux.&lt;/p&gt;

&lt;p&gt;It's that a relatively small technical project can become enormously important when:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The problem is interesting.&lt;/li&gt;
&lt;li&gt;The implementation is useful.&lt;/li&gt;
&lt;li&gt;The project is shared with others.&lt;/li&gt;
&lt;li&gt;Developers can contribute.&lt;/li&gt;
&lt;li&gt;The software continues to evolve.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Linux demonstrates the power of collaborative engineering.&lt;/p&gt;

&lt;p&gt;Git demonstrates the importance of tools that make collaboration possible.&lt;/p&gt;

&lt;p&gt;Together, they have had an enormous influence on modern software development.&lt;/p&gt;




&lt;h1&gt;
  
  
  If You Want to Follow a Similar Learning Path
&lt;/h1&gt;

&lt;p&gt;You don't need to try to become "the next Linus Torvalds."&lt;/p&gt;

&lt;p&gt;Instead, focus on becoming a strong programmer.&lt;/p&gt;

&lt;p&gt;A practical path could look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;C Programming
      ↓
Data Structures
      ↓
Algorithms
      ↓
Linux
      ↓
Systems Programming
      ↓
Computer Architecture
      ↓
Operating Systems
      ↓
Networking
      ↓
Filesystems
      ↓
Databases
      ↓
Large Software Projects
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then build projects.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Project 1 → Shell
Project 2 → Text Editor
Project 3 → HTTP Server
Project 4 → Database
Project 5 → Filesystem
Project 6 → Compiler
Project 7 → Small Operating System
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each project forces you to learn another part of computer science.&lt;/p&gt;




&lt;h1&gt;
  
  
  Final Thoughts
&lt;/h1&gt;

&lt;p&gt;Linus Torvalds' career is a remarkable example of how software can grow from a personal experiment into infrastructure used around the world.&lt;/p&gt;

&lt;p&gt;Linux changed operating systems.&lt;/p&gt;

&lt;p&gt;Git changed how developers manage source code.&lt;/p&gt;

&lt;p&gt;But perhaps the most valuable lesson is simpler:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Build things.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Don't wait until you understand everything.&lt;/p&gt;

&lt;p&gt;Start with a manageable problem.&lt;/p&gt;

&lt;p&gt;Write the code.&lt;/p&gt;

&lt;p&gt;Break it.&lt;/p&gt;

&lt;p&gt;Debug it.&lt;/p&gt;

&lt;p&gt;Read documentation.&lt;/p&gt;

&lt;p&gt;Study other implementations.&lt;/p&gt;

&lt;p&gt;Improve it.&lt;/p&gt;

&lt;p&gt;Then build something harder.&lt;/p&gt;

&lt;p&gt;That's how small programming projects turn into serious engineering experience.&lt;/p&gt;

&lt;p&gt;And that's one of the most important lessons we can take from the story of &lt;strong&gt;Linus Torvalds, Linux, and Git&lt;/strong&gt;.&lt;/p&gt;

</description>
      <category>linux</category>
      <category>git</category>
      <category>code</category>
      <category>productivity</category>
    </item>
    <item>
      <title>How to Build Your Own SQLite Database From Scratch</title>
      <dc:creator>Farhad Rahimi Klie</dc:creator>
      <pubDate>Sun, 16 Aug 2026 05:31:33 +0000</pubDate>
      <link>https://dev.to/farhadrahimiklie/how-to-build-your-own-sqlite-database-from-scratch-2lcm</link>
      <guid>https://dev.to/farhadrahimiklie/how-to-build-your-own-sqlite-database-from-scratch-2lcm</guid>
      <description>&lt;p&gt;Have you ever wondered what actually happens when you run a SQL query like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;users&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Where is the data stored?&lt;/p&gt;

&lt;p&gt;How does the database find the correct row?&lt;/p&gt;

&lt;p&gt;How are tables represented on disk?&lt;/p&gt;

&lt;p&gt;How does the database survive after the program exits?&lt;/p&gt;

&lt;p&gt;And how does a database engine turn SQL into operations on bytes, pages, indexes, and files?&lt;/p&gt;

&lt;p&gt;Instead of only using a database, let's build a small &lt;strong&gt;SQLite-like database engine from scratch in C&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;We won't try to recreate all of SQLite. That would be an enormous project. Instead, we'll build a small educational database engine that teaches the fundamental architecture behind relational databases.&lt;/p&gt;

&lt;p&gt;By the end, we'll understand how the pieces fit together:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;                 SQL Query
                    │
                    ▼
             ┌─────────────┐
             │ SQL Parser  │
             └──────┬──────┘
                    │
                    ▼
             ┌─────────────┐
             │ Query Plan  │
             └──────┬──────┘
                    │
                    ▼
             ┌─────────────┐
             │   Executor  │
             └──────┬──────┘
                    │
                    ▼
             ┌─────────────┐
             │    B-Tree   │
             └──────┬──────┘
                    │
                    ▼
             ┌─────────────┐
             │ Buffer Pool │
             └──────┬──────┘
                    │
                    ▼
             ┌─────────────┐
             │ Disk / File │
             └─────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's build it step by step.&lt;/p&gt;




&lt;h2&gt;
  
  
  1. What Are We Actually Building?
&lt;/h2&gt;

&lt;p&gt;Our goal is a small database executable:&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="nv"&gt;$ &lt;/span&gt;./mydb database.db
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then we can interact with it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;db &amp;gt; CREATE TABLE users;
db &amp;gt; INSERT INTO users VALUES (1, "Farhad");
db &amp;gt; INSERT INTO users VALUES (2, "Ali");
db &amp;gt; SELECT * FROM users;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And eventually:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1 | Farhad
2 | Ali
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The important part is that the data should remain after the program exits.&lt;/p&gt;

&lt;p&gt;If we run:&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="nv"&gt;$ &lt;/span&gt;./mydb database.db
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;again, the database should still contain:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1 | Farhad
2 | Ali
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That means we need persistent storage.&lt;/p&gt;




&lt;h1&gt;
  
  
  2. Why C?
&lt;/h1&gt;

&lt;p&gt;C is an excellent language for learning how databases work internally because it gives us direct control over:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;memory&lt;/li&gt;
&lt;li&gt;pointers&lt;/li&gt;
&lt;li&gt;structs&lt;/li&gt;
&lt;li&gt;files&lt;/li&gt;
&lt;li&gt;byte arrays&lt;/li&gt;
&lt;li&gt;serialization&lt;/li&gt;
&lt;li&gt;memory allocation&lt;/li&gt;
&lt;li&gt;system calls&lt;/li&gt;
&lt;li&gt;data structures&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A database engine ultimately deals with a lot of low-level concepts.&lt;/p&gt;

&lt;p&gt;For example, a database page might simply be:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="kt"&gt;unsigned&lt;/span&gt; &lt;span class="kt"&gt;char&lt;/span&gt; &lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;4096&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Those 4096 bytes could contain:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;+----------------------------------+
| Page Header                      |
+----------------------------------+
| Slot Array                       |
+----------------------------------+
|                                  |
| Records                          |
|                                  |
+----------------------------------+
| Free Space                       |
+----------------------------------+
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At this level, there is no magic.&lt;/p&gt;

&lt;p&gt;It's bytes.&lt;/p&gt;

&lt;p&gt;Our job is to give those bytes meaning.&lt;/p&gt;




&lt;h1&gt;
  
  
  3. The Architecture
&lt;/h1&gt;

&lt;p&gt;Before writing code, we need an architecture.&lt;/p&gt;

&lt;p&gt;A simplified database can be divided into several layers:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;┌───────────────────────────────┐
│          SQL Layer            │
│ Lexer / Parser / Statements   │
├───────────────────────────────┤
│        Query Executor         │
├───────────────────────────────┤
│       Access Methods          │
│       Table / B-Tree          │
├───────────────────────────────┤
│         Buffer Pool           │
├───────────────────────────────┤
│          Page Cache           │
├───────────────────────────────┤
│        Storage Manager        │
├───────────────────────────────┤
│        Database File          │
└───────────────────────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We'll implement these components incrementally.&lt;/p&gt;




&lt;h1&gt;
  
  
  4. Step 1 — The Database File
&lt;/h1&gt;

&lt;p&gt;The simplest database can start as a normal file.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;database.db
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can open it with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="kt"&gt;FILE&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;file&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;fopen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"database.db"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"r+b"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or create it if it doesn't exist:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="kt"&gt;FILE&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;file&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;fopen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"database.db"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"w+b"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But simply writing random structures into a file isn't enough.&lt;/p&gt;

&lt;p&gt;We need a storage format.&lt;/p&gt;




&lt;h1&gt;
  
  
  5. Step 2 — Pages
&lt;/h1&gt;

&lt;p&gt;Databases generally don't treat the disk as one giant byte array.&lt;/p&gt;

&lt;p&gt;Instead, we divide the database file into fixed-size pages.&lt;/p&gt;

&lt;p&gt;For our educational database:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="cp"&gt;#define PAGE_SIZE 4096
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A database file might look like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;database.db

┌──────────────┐
│ Page 0       │
│ 4096 bytes   │
├──────────────┤
│ Page 1       │
│ 4096 bytes   │
├──────────────┤
│ Page 2       │
│ 4096 bytes   │
├──────────────┤
│ Page 3       │
│ 4096 bytes   │
├──────────────┤
│ ...          │
└──────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the database has 100 pages:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;100 × 4096 = 409,600 bytes
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A page gives us a fixed unit for storage and caching.&lt;/p&gt;




&lt;h1&gt;
  
  
  6. Why Pages?
&lt;/h1&gt;

&lt;p&gt;Suppose we need record number 500.&lt;/p&gt;

&lt;p&gt;We don't want to read the entire database file.&lt;/p&gt;

&lt;p&gt;Instead, we determine which page contains the record:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;record
   │
   ▼
page number
   │
   ▼
database file offset
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The offset is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="n"&gt;offset&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;page_number&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;PAGE_SIZE&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;page = 10

offset = 10 × 4096
       = 40960
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So page 10 begins at byte 40960.&lt;/p&gt;




&lt;h1&gt;
  
  
  7. Step 3 — The Pager
&lt;/h1&gt;

&lt;p&gt;Now we create one of the most important components:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;the pager.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The pager is responsible for moving pages between the database file and memory.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;             RAM
       ┌──────────────┐
       │ Page 0       │
       │ Page 4       │
       │ Page 7       │
       └───────┬──────┘
               │
               │
          ┌────▼────┐
          │  Pager  │
          └────┬────┘
               │
               ▼
       ┌──────────────┐
       │ database.db  │
       └──────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A basic pager structure might look like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="cp"&gt;#define TABLE_MAX_PAGES 100
&lt;/span&gt;
&lt;span class="k"&gt;typedef&lt;/span&gt; &lt;span class="k"&gt;struct&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;file_descriptor&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kt"&gt;uint32_t&lt;/span&gt; &lt;span class="n"&gt;file_length&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;pages&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;TABLE_MAX_PAGES&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="n"&gt;Pager&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;pages&lt;/code&gt; array stores pointers to pages currently loaded in memory.&lt;/p&gt;




&lt;h1&gt;
  
  
  8. Loading a Page
&lt;/h1&gt;

&lt;p&gt;Suppose we request page 5.&lt;/p&gt;

&lt;p&gt;The pager checks:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pager&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;pages&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="nb"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If it isn't loaded, allocate memory:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="n"&gt;pager&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;pages&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;malloc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;PAGE_SIZE&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then read the page from disk.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;database.db
     │
     │ read page 5
     ▼
┌─────────────┐
│ Page 5      │
└─────────────┘
     │
     ▼
RAM
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is the beginning of a buffer pool/cache.&lt;/p&gt;




&lt;h1&gt;
  
  
  9. Step 4 — Rows
&lt;/h1&gt;

&lt;p&gt;Now we need to decide how a table row is represented.&lt;/p&gt;

&lt;p&gt;For a simple database, let's define:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="k"&gt;typedef&lt;/span&gt; &lt;span class="k"&gt;struct&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kt"&gt;uint32_t&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kt"&gt;char&lt;/span&gt; &lt;span class="n"&gt;username&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;32&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
    &lt;span class="kt"&gt;char&lt;/span&gt; &lt;span class="n"&gt;email&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;64&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="n"&gt;Row&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A row might contain:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;id       = 1
username = "Farhad"
email    = "farhad@example.com"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But we cannot simply assume that a C struct's memory layout is our database format.&lt;/p&gt;

&lt;p&gt;We should explicitly serialize the row.&lt;/p&gt;




&lt;h1&gt;
  
  
  10. Serialization
&lt;/h1&gt;

&lt;p&gt;Serialization means converting a C structure into bytes.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;C structure

Row
┌───────────────┐
│ id            │
├───────────────┤
│ username      │
├───────────────┤
│ email         │
└───────────────┘
       │
       ▼
   serialize
       │
       ▼
Bytes on disk
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can write:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;serialize_row&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Row&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;source&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;destination&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;memcpy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;destination&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;source&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;sizeof&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;source&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;

    &lt;span class="n"&gt;memcpy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;destination&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
           &lt;span class="n"&gt;source&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;username&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
           &lt;span class="k"&gt;sizeof&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;source&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;username&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;

    &lt;span class="n"&gt;memcpy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;destination&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;36&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
           &lt;span class="n"&gt;source&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;email&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
           &lt;span class="k"&gt;sizeof&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;source&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;email&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And later deserialize it.&lt;/p&gt;

&lt;p&gt;This is important because the database file needs a well-defined format.&lt;/p&gt;




&lt;h1&gt;
  
  
  11. Step 5 — The Table
&lt;/h1&gt;

&lt;p&gt;Now we can store rows inside pages.&lt;/p&gt;

&lt;p&gt;Initially, we could use a very simple layout:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Page
┌──────────────────────────────┐
│ Row 0                        │
├──────────────────────────────┤
│ Row 1                        │
├──────────────────────────────┤
│ Row 2                        │
├──────────────────────────────┤
│ Row 3                        │
├──────────────────────────────┤
│ ...                          │
└──────────────────────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="cp"&gt;#define ROW_SIZE 100
&lt;/span&gt;
&lt;span class="cp"&gt;#define ROWS_PER_PAGE \
    (PAGE_SIZE / ROW_SIZE)
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="n"&gt;page_number&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;row_number&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;ROWS_PER_PAGE&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;row_offset&lt;/span&gt;  &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;row_number&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="n"&gt;ROWS_PER_PAGE&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This gives us a simple way to locate rows.&lt;/p&gt;




&lt;h1&gt;
  
  
  12. Step 6 — The REPL
&lt;/h1&gt;

&lt;p&gt;Now let's create an interface.&lt;/p&gt;

&lt;p&gt;A REPL means:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Read → Evaluate → Print → Loop&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Our program could display:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;db &amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The user enters:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;db &amp;gt; insert 1 Farhad
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Our program reads the input:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="kt"&gt;char&lt;/span&gt; &lt;span class="n"&gt;input&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1024&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;

&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"db &amp;gt; "&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;fgets&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;input&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;sizeof&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;input&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;stdin&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
        &lt;span class="k"&gt;break&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="c1"&gt;// process input&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At first, don't implement SQL.&lt;/p&gt;

&lt;p&gt;Start with commands like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;insert
select
.exit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This makes development much easier.&lt;/p&gt;




&lt;h1&gt;
  
  
  13. Step 7 — INSERT
&lt;/h1&gt;

&lt;p&gt;Suppose the user enters:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;insert 1 Farhad
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The database needs to:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Input
 │
 ▼
Parse command
 │
 ▼
Create Row
 │
 ▼
Serialize Row
 │
 ▼
Find page
 │
 ▼
Write Row
 │
 ▼
Mark page dirty
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="n"&gt;Row&lt;/span&gt; &lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;strcpy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;username&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Farhad"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="n"&gt;execute_insert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h1&gt;
  
  
  14. Step 8 — SELECT
&lt;/h1&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;select
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;should read all rows.&lt;/p&gt;

&lt;p&gt;The executor might:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;for each page
    load page

    for each row
        deserialize row

        print row
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;database
   │
   ▼
Page 0
   │
   ├── Row 0
   ├── Row 1
   └── Row 2

Page 1
   │
   ├── Row 3
   ├── Row 4
   └── Row 5
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is essentially a table scan.&lt;/p&gt;




&lt;h1&gt;
  
  
  15. Step 9 — From Commands to SQL
&lt;/h1&gt;

&lt;p&gt;Once the storage engine works, we can start implementing SQL.&lt;/p&gt;

&lt;p&gt;Instead of:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;insert 1 Farhad
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;we want:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;INSERT&lt;/span&gt; &lt;span class="k"&gt;INTO&lt;/span&gt; &lt;span class="n"&gt;users&lt;/span&gt; &lt;span class="k"&gt;VALUES&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'Farhad'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;users&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we need a lexer and parser.&lt;/p&gt;




&lt;h1&gt;
  
  
  16. The SQL Lexer
&lt;/h1&gt;

&lt;p&gt;The lexer converts characters into tokens.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;users&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;we might produce:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT
ASTERISK
FROM
IDENTIFIER(users)
SEMICOLON
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The input:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT * FROM users;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;┌────────┐
│ SELECT │
├────────┤
│   *    │
├────────┤
│  FROM  │
├────────┤
│ users  │
├────────┤
│   ;    │
└────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h1&gt;
  
  
  17. The Parser
&lt;/h1&gt;

&lt;p&gt;The parser takes those tokens and builds a representation of the query.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;users&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;could become:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SelectStatement
├── columns: *
└── table: users
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;INSERT&lt;/span&gt; &lt;span class="k"&gt;INTO&lt;/span&gt; &lt;span class="n"&gt;users&lt;/span&gt; &lt;span class="k"&gt;VALUES&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'Farhad'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;we could create:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;InsertStatement
├── table: users
└── values
    ├── 1
    └── Farhad
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h1&gt;
  
  
  18. Step 10 — The Query Executor
&lt;/h1&gt;

&lt;p&gt;The parser tells us &lt;strong&gt;what the user wants&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The executor determines &lt;strong&gt;how to perform it&lt;/strong&gt;.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;users&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;might become:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Parser
   │
   ▼
SELECT statement
   │
   ▼
Executor
   │
   ▼
Table scan
   │
   ▼
Read pages
   │
   ▼
Read rows
   │
   ▼
Return results
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This separation is extremely important.&lt;/p&gt;




&lt;h1&gt;
  
  
  19. Step 11 — Slotted Pages
&lt;/h1&gt;

&lt;p&gt;Our first page layout was very simple.&lt;/p&gt;

&lt;p&gt;A real database needs a more flexible structure.&lt;/p&gt;

&lt;p&gt;This is where &lt;strong&gt;slotted pages&lt;/strong&gt; become useful.&lt;/p&gt;

&lt;p&gt;A page might look like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;┌─────────────────────────────┐
│ Page Header                 │
├─────────────────────────────┤
│ Slot 0                      │
├─────────────────────────────┤
│ Slot 1                      │
├─────────────────────────────┤
│ Slot 2                      │
├─────────────────────────────┤
│                             │
│ Free Space                  │
│                             │
├─────────────────────────────┤
│ Record 2                    │
├─────────────────────────────┤
│ Record 1                    │
├─────────────────────────────┤
│ Record 0                    │
└─────────────────────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The slot array tells us where records are located.&lt;/p&gt;

&lt;p&gt;This allows records to have variable sizes and move around within a page without changing their logical identifiers.&lt;/p&gt;




&lt;h1&gt;
  
  
  20. Step 12 — Record IDs
&lt;/h1&gt;

&lt;p&gt;Instead of identifying a record simply by its memory address, we can use a logical identifier.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;RID
├── page_id
└── slot_id
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;RID = (12, 4)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Page 12
Slot 4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This gives us a stable way to refer to records.&lt;/p&gt;




&lt;h1&gt;
  
  
  21. Step 13 — Free Space Management
&lt;/h1&gt;

&lt;p&gt;Eventually pages become full.&lt;/p&gt;

&lt;p&gt;We need to know:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Which pages have free space?
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A simple free-space map could track this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Page 0 → full
Page 1 → 1200 bytes free
Page 2 → full
Page 3 → 3000 bytes free
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When inserting a record, the storage manager searches for a page with enough free space.&lt;/p&gt;

&lt;p&gt;This is one of the fundamental responsibilities of a storage engine.&lt;/p&gt;




&lt;h1&gt;
  
  
  22. Step 14 — B-Tree Indexes
&lt;/h1&gt;

&lt;p&gt;A table scan works:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;users&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1000000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But it can be very slow.&lt;/p&gt;

&lt;p&gt;If there are one million rows, scanning every row is expensive.&lt;/p&gt;

&lt;p&gt;We need an index.&lt;/p&gt;

&lt;p&gt;A common database index structure is a &lt;strong&gt;B-tree&lt;/strong&gt; or &lt;strong&gt;B+ tree&lt;/strong&gt;.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;                  [50]
                /      \
              /          \
         [10,20,30]     [60,70,80]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The index lets us navigate toward the desired key instead of scanning every row.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;70&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;we navigate:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;          [50]
            \
             ▼
       [60,70,80]
            │
            ▼
          row 70
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h1&gt;
  
  
  23. Why B-Trees?
&lt;/h1&gt;

&lt;p&gt;B-trees are particularly useful for storage systems because they reduce the number of disk/page accesses required to locate records.&lt;/p&gt;

&lt;p&gt;Instead of:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Page 0
Page 1
Page 2
Page 3
...
Page 1,000,000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;we can navigate through a tree:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;             Root
              │
       ┌──────┴──────┐
       ▼             ▼
    Internal       Internal
       │             │
       ▼             ▼
     Leaves         Leaves
       │
       ▼
     Record
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The database doesn't have to inspect every row.&lt;/p&gt;




&lt;h1&gt;
  
  
  24. Step 15 — Buffer Pool
&lt;/h1&gt;

&lt;p&gt;Disk is much slower than RAM.&lt;/p&gt;

&lt;p&gt;Therefore, databases keep frequently used pages in memory.&lt;/p&gt;

&lt;p&gt;A buffer pool might look like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;RAM

┌───────────────┐
│ Frame 0       │ → Page 17
├───────────────┤
│ Frame 1       │ → Page 4
├───────────────┤
│ Frame 2       │ → Page 31
├───────────────┤
│ Frame 3       │ → Page 9
└───────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When the database requests page 17:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Request Page 17
      │
      ▼
Is it in buffer?
      │
   ┌──┴──┐
  yes    no
   │      │
   ▼      ▼
 return  read disk
          │
          ▼
       buffer
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This dramatically reduces disk I/O.&lt;/p&gt;




&lt;h1&gt;
  
  
  25. Dirty Pages
&lt;/h1&gt;

&lt;p&gt;Suppose we load a page:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Disk → RAM
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then modify it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;RAM
Page 5
  │
  └── modified
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The page is now &lt;strong&gt;dirty&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Eventually we need:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;RAM → Disk
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So a buffer frame might have:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="k"&gt;typedef&lt;/span&gt; &lt;span class="k"&gt;struct&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kt"&gt;uint32_t&lt;/span&gt; &lt;span class="n"&gt;page_id&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;dirty&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="n"&gt;Frame&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="n"&gt;frame&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;dirty&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;we know the page must eventually be written back.&lt;/p&gt;




&lt;h1&gt;
  
  
  26. Step 16 — Transactions
&lt;/h1&gt;

&lt;p&gt;Now we reach a much more serious database feature.&lt;/p&gt;

&lt;p&gt;What happens if the program crashes halfway through a write?&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Transaction:

1. Update row A
2. Update row B
3. Program crashes
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We don't want the database to end up in an inconsistent state.&lt;/p&gt;

&lt;p&gt;Transactions provide atomicity.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;BEGIN
   │
   ├── operation 1
   ├── operation 2
   ├── operation 3
   │
COMMIT
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;BEGIN
   │
   ├── operation 1
   ├── operation 2
   │
ROLLBACK
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h1&gt;
  
  
  27. Step 17 — Write-Ahead Logging
&lt;/h1&gt;

&lt;p&gt;A common technique is &lt;strong&gt;Write-Ahead Logging (WAL)&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Before modifying the actual database page, record the change in a log.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;             Transaction
                  │
                  ▼
             Write Log
                  │
                  ▼
             Modify Page
                  │
                  ▼
               Commit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the database crashes, the log can be used during recovery.&lt;/p&gt;

&lt;p&gt;This is one of the major steps from a toy database toward a real database engine.&lt;/p&gt;




&lt;h1&gt;
  
  
  28. Step 18 — Database Catalog
&lt;/h1&gt;

&lt;p&gt;Once we support multiple tables, the database needs metadata.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;TABLE&lt;/span&gt; &lt;span class="n"&gt;users&lt;/span&gt; &lt;span class="p"&gt;(...);&lt;/span&gt;
&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;TABLE&lt;/span&gt; &lt;span class="n"&gt;products&lt;/span&gt; &lt;span class="p"&gt;(...);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The database needs to know:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;users
 ├── columns
 ├── types
 └── root page

products
 ├── columns
 ├── types
 └── root page
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This metadata is often called the &lt;strong&gt;system catalog&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Our catalog could contain information such as:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Table name
Column name
Column type
Column position
Index information
Root page
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h1&gt;
  
  
  29. Step 19 — Data Types
&lt;/h1&gt;

&lt;p&gt;Eventually our SQL engine should understand:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;INTEGER
TEXT
REAL
BOOLEAN
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;TABLE&lt;/span&gt; &lt;span class="n"&gt;users&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="nb"&gt;INTEGER&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="nb"&gt;TEXT&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;age&lt;/span&gt; &lt;span class="nb"&gt;INTEGER&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Internally, a row might be serialized as:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;┌──────────┬────────────┬──────────┐
│ id       │ name       │ age      │
│ INTEGER  │ TEXT       │ INTEGER  │
└──────────┴────────────┴──────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The serialization layer needs to understand each type.&lt;/p&gt;




&lt;h1&gt;
  
  
  30. Step 20 — Query Execution
&lt;/h1&gt;

&lt;p&gt;Eventually we want queries such as:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;users&lt;/span&gt;
&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;age&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;18&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The execution pipeline becomes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SQL
 │
 ▼
Lexer
 │
 ▼
Parser
 │
 ▼
AST
 │
 ▼
Query Planner
 │
 ▼
Execution Plan
 │
 ▼
Executor
 │
 ▼
Index / Table Scan
 │
 ▼
Pages
 │
 ▼
Rows
 │
 ▼
Result
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is where our database starts becoming a real database engine rather than a file-based storage program.&lt;/p&gt;




&lt;h1&gt;
  
  
  31. A Practical Development Roadmap
&lt;/h1&gt;

&lt;p&gt;Don't try to build everything at once.&lt;/p&gt;

&lt;p&gt;Build the database in stages.&lt;/p&gt;

&lt;h3&gt;
  
  
  Stage 1 — File Storage
&lt;/h3&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;database file
page size
read page
write page
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Stage 2 — Pager
&lt;/h3&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Pager
page cache
page loading
page flushing
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Stage 3 — Rows
&lt;/h3&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Row
serialize
deserialize
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Stage 4 — Table
&lt;/h3&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;insert
select
table scan
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Stage 5 — REPL
&lt;/h3&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;db &amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;with commands such as:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.insert
.select
.exit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Stage 6 — SQL Lexer
&lt;/h3&gt;

&lt;p&gt;Implement tokens:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT
INSERT
CREATE
FROM
WHERE
INTEGER
TEXT
IDENTIFIER
NUMBER
STRING
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Stage 7 — SQL Parser
&lt;/h3&gt;

&lt;p&gt;Build an AST for SQL statements.&lt;/p&gt;

&lt;h3&gt;
  
  
  Stage 8 — Slotted Pages
&lt;/h3&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;page header
slot directory
records
free space
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Stage 9 — B-Tree
&lt;/h3&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;leaf nodes
internal nodes
search
insert
split
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Stage 10 — Catalog
&lt;/h3&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;tables
columns
types
indexes
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Stage 11 — Query Execution
&lt;/h3&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;table scan
index scan
filter
projection
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Stage 12 — Transactions
&lt;/h3&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;BEGIN
COMMIT
ROLLBACK
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Stage 13 — WAL and Recovery
&lt;/h3&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;log
checkpoint
recovery
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Stage 14 — Concurrency
&lt;/h3&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;locks
latches
transactions
isolation
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h1&gt;
  
  
  32. Suggested Project Structure
&lt;/h1&gt;

&lt;p&gt;A clean project might eventually look like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mydb/
│
├── src/
│   ├── main.c
│   ├── repl.c
│   ├── lexer.c
│   ├── parser.c
│   ├── executor.c
│   ├── catalog.c
│   ├── table.c
│   ├── row.c
│   ├── page.c
│   ├── pager.c
│   ├── buffer_pool.c
│   ├── btree.c
│   ├── transaction.c
│   ├── wal.c
│   └── recovery.c
│
├── include/
│   ├── repl.h
│   ├── lexer.h
│   ├── parser.h
│   ├── executor.h
│   ├── catalog.h
│   ├── table.h
│   ├── row.h
│   ├── page.h
│   ├── pager.h
│   ├── buffer_pool.h
│   ├── btree.h
│   ├── transaction.h
│   ├── wal.h
│   └── recovery.h
│
├── tests/
│   ├── test_pager.c
│   ├── test_page.c
│   ├── test_btree.c
│   └── test_sql.c
│
├── Makefile
└── database.db
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You don't need all of these files on day one.&lt;/p&gt;

&lt;p&gt;Start small and grow the architecture as the database becomes more capable.&lt;/p&gt;




&lt;h1&gt;
  
  
  33. The Most Important Concept
&lt;/h1&gt;

&lt;p&gt;The biggest lesson from building a database from scratch is this:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A database is not just SQL.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;SQL is only the interface.&lt;/p&gt;

&lt;p&gt;Underneath SQL are many layers:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SQL
 ↓
Parser
 ↓
Query Planner
 ↓
Executor
 ↓
Indexes
 ↓
Tables
 ↓
Records
 ↓
Pages
 ↓
Buffer Pool
 ↓
Storage Manager
 ↓
Operating System
 ↓
Disk
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And underneath all of that:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;bytes
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Understanding those layers gives you a completely different perspective on databases.&lt;/p&gt;




&lt;h1&gt;
  
  
  34. What We Should Not Build Initially
&lt;/h1&gt;

&lt;p&gt;A common mistake is trying to implement everything immediately.&lt;/p&gt;

&lt;p&gt;Don't start with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SQL
Transactions
WAL
Concurrency
B-Trees
Joins
Indexes
Networking
Replication
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;all at once.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;file
 ↓
pages
 ↓
pager
 ↓
rows
 ↓
table
 ↓
insert/select
 ↓
B-tree
 ↓
SQL
 ↓
transactions
 ↓
WAL
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each stage should work before moving to the next.&lt;/p&gt;




&lt;h1&gt;
  
  
  35. Final Architecture
&lt;/h1&gt;

&lt;p&gt;Our final educational database could look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;                    USER
                     │
                     ▼
              ┌─────────────┐
              │     SQL     │
              └──────┬──────┘
                     ▼
              ┌─────────────┐
              │    Lexer    │
              └──────┬──────┘
                     ▼
              ┌─────────────┐
              │    Parser   │
              └──────┬──────┘
                     ▼
              ┌─────────────┐
              │Query Planner│
              └──────┬──────┘
                     ▼
              ┌─────────────┐
              │   Executor  │
              └──────┬──────┘
                     ▼
           ┌─────────┴─────────┐
           │                   │
           ▼                   ▼
      Table Scan            B-Tree
           │                   │
           └─────────┬─────────┘
                     ▼
              ┌─────────────┐
              │ Buffer Pool │
              └──────┬──────┘
                     ▼
              ┌─────────────┐
              │    Pager    │
              └──────┬──────┘
                     ▼
              ┌─────────────┐
              │ Database DB │
              │    File     │
              └─────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;Building a SQLite-like database from scratch is one of the best projects for learning systems programming.&lt;/p&gt;

&lt;p&gt;You will learn far more than SQL.&lt;/p&gt;

&lt;p&gt;You'll learn:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;C programming&lt;/li&gt;
&lt;li&gt;memory management&lt;/li&gt;
&lt;li&gt;binary data&lt;/li&gt;
&lt;li&gt;file I/O&lt;/li&gt;
&lt;li&gt;serialization&lt;/li&gt;
&lt;li&gt;page layouts&lt;/li&gt;
&lt;li&gt;storage engines&lt;/li&gt;
&lt;li&gt;buffer pools&lt;/li&gt;
&lt;li&gt;indexing&lt;/li&gt;
&lt;li&gt;B-trees&lt;/li&gt;
&lt;li&gt;parsing&lt;/li&gt;
&lt;li&gt;query execution&lt;/li&gt;
&lt;li&gt;transactions&lt;/li&gt;
&lt;li&gt;logging&lt;/li&gt;
&lt;li&gt;crash recovery&lt;/li&gt;
&lt;li&gt;operating-system I/O&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The important thing is to build it &lt;strong&gt;incrementally&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Don't begin by asking:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"How do I build SQLite?"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Start by asking:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"How do I store one page?"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Then:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"How do I store one row?"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Then:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"How do I find that row?"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Then:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"How do I find millions of rows efficiently?"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Then:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"How do I make the operation safe if the program crashes?"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That's how a database engine grows—from a few thousand bytes of C code into a complete storage system.&lt;/p&gt;

&lt;p&gt;And the best part is that every layer you implement gives you a deeper understanding of what databases are actually doing underneath the SQL interface.&lt;/p&gt;

</description>
      <category>sqlite</category>
      <category>code</category>
      <category>programming</category>
      <category>c</category>
    </item>
    <item>
      <title>GitHub Doesn't Get “Hacked” the Way You Think</title>
      <dc:creator>Farhad Rahimi Klie</dc:creator>
      <pubDate>Mon, 10 Aug 2026 03:59:05 +0000</pubDate>
      <link>https://dev.to/farhadrahimiklie/github-doesnt-get-hacked-the-way-you-think-1c5l</link>
      <guid>https://dev.to/farhadrahimiklie/github-doesnt-get-hacked-the-way-you-think-1c5l</guid>
      <description>&lt;p&gt;There is a dangerous misconception in software security:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“If someone hacked GitHub, they must have broken through GitHub's login page.”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Usually, that's not how modern attacks work.&lt;/p&gt;

&lt;p&gt;The most interesting attacks don't necessarily defeat the strongest lock.&lt;/p&gt;

&lt;p&gt;They find a different door.&lt;/p&gt;

&lt;p&gt;A stolen OAuth token.&lt;/p&gt;

&lt;p&gt;A compromised developer account.&lt;/p&gt;

&lt;p&gt;A leaked secret.&lt;/p&gt;

&lt;p&gt;A malicious dependency.&lt;/p&gt;

&lt;p&gt;A vulnerable production service.&lt;/p&gt;

&lt;p&gt;A trusted third-party integration.&lt;/p&gt;

&lt;p&gt;A phishing attack.&lt;/p&gt;

&lt;p&gt;A forgotten permission.&lt;/p&gt;

&lt;p&gt;And once an attacker obtains a legitimate credential, the attack can look like completely normal activity.&lt;/p&gt;

&lt;p&gt;That's what makes these attacks dangerous.&lt;/p&gt;




&lt;h2&gt;
  
  
  GitHub Is a Giant Trust System
&lt;/h2&gt;

&lt;p&gt;Think about what a modern GitHub account can connect to:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Developer
    |
    +---- GitHub account
    |
    +---- Organizations
    |
    +---- Private repositories
    |
    +---- GitHub Actions
    |
    +---- OAuth applications
    |
    +---- Personal access tokens
    |
    +---- SSH keys
    |
    +---- Cloud credentials
    |
    +---- Package registries
    |
    +---- Deployment systems
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;GitHub isn't isolated.&lt;/p&gt;

&lt;p&gt;It sits inside a much larger software ecosystem.&lt;/p&gt;

&lt;p&gt;That means an attacker doesn't always need to attack GitHub directly.&lt;/p&gt;

&lt;p&gt;They may attack something that &lt;strong&gt;already has permission to talk to GitHub&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;And that distinction changes everything.&lt;/p&gt;




&lt;h1&gt;
  
  
  Attack #1: Steal the Key Instead of Breaking the Lock
&lt;/h1&gt;

&lt;p&gt;One of the clearest examples happened in 2022.&lt;/p&gt;

&lt;p&gt;GitHub disclosed an attack campaign involving stolen OAuth user tokens issued to third-party integrations, specifically Heroku and Travis CI.&lt;/p&gt;

&lt;p&gt;The attacker used those stolen tokens to access GitHub APIs and selectively identify organizations and private repositories.&lt;/p&gt;

&lt;p&gt;GitHub said it did &lt;strong&gt;not&lt;/strong&gt; believe the attacker obtained those tokens by compromising GitHub itself.&lt;/p&gt;

&lt;p&gt;Think about the architecture:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;                 ┌──────────────┐
                 │   GitHub     │
                 └──────┬───────┘
                        │
                  OAuth trust
                        │
             ┌──────────┴──────────┐
             │                     │
        Third-party App       Third-party App
             │                     │
          Heroku              Travis CI
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The attacker didn't necessarily need:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;GitHub password
        ↓
GitHub login
        ↓
GitHub account
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Instead, the attack path was conceptually:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Compromised integration
        ↓
Stolen OAuth token
        ↓
GitHub API authentication
        ↓
Authorized permissions
        ↓
Private repository access
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's a completely different security model.&lt;/p&gt;

&lt;p&gt;The server sees a valid credential.&lt;/p&gt;

&lt;p&gt;The credential has permission.&lt;/p&gt;

&lt;p&gt;The request can therefore look legitimate.&lt;/p&gt;




&lt;h1&gt;
  
  
  The Most Dangerous Credential Is the One That Looks Legitimate
&lt;/h1&gt;

&lt;p&gt;This is a fundamental security lesson.&lt;/p&gt;

&lt;p&gt;Imagine a server receives:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Authorization: valid-token
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The server doesn't automatically know:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"An attacker stole this token yesterday."
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It sees:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;valid credential
+
valid permission
+
valid API request
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That is why credential theft can be so powerful.&lt;/p&gt;

&lt;p&gt;You don't necessarily need to defeat authentication.&lt;/p&gt;

&lt;p&gt;You can sometimes become the authenticated user.&lt;/p&gt;




&lt;h1&gt;
  
  
  Attack #2: Phishing the Developer
&lt;/h1&gt;

&lt;p&gt;Another attack path is much simpler:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Attacker
   |
   | fake login page
   v
Developer
   |
   | enters credentials
   v
Attacker
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;GitHub documented a phishing campaign in which attackers created convincing login pages.&lt;/p&gt;

&lt;p&gt;The important part was that even some accounts using TOTP-based two-factor authentication could be targeted because the phishing site relayed authentication information in real time.&lt;/p&gt;

&lt;p&gt;GitHub noted that hardware security keys were not vulnerable to that particular attack technique.&lt;/p&gt;

&lt;p&gt;This demonstrates an important distinction:&lt;/p&gt;

&lt;h3&gt;
  
  
  Authentication ≠ phishing resistance
&lt;/h3&gt;

&lt;p&gt;A security mechanism can be strong while still being vulnerable to a particular social-engineering technique.&lt;/p&gt;

&lt;p&gt;That's one reason phishing-resistant authentication matters.&lt;/p&gt;




&lt;h1&gt;
  
  
  Attack #3: Steal a Token After Taking the Account
&lt;/h1&gt;

&lt;p&gt;Here's where attacks become interesting.&lt;/p&gt;

&lt;p&gt;Suppose an attacker compromises a developer account.&lt;/p&gt;

&lt;p&gt;The attacker doesn't necessarily stop there.&lt;/p&gt;

&lt;p&gt;They may look for additional ways to maintain access.&lt;/p&gt;

&lt;p&gt;GitHub documented attackers attempting to create personal access tokens, authorize OAuth applications, or add SSH keys after obtaining account credentials.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Account compromise
        |
        +---- Password
        |
        +---- PAT
        |
        +---- OAuth application
        |
        +---- SSH key
        |
        +---- Repository permissions
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Why?&lt;/p&gt;

&lt;p&gt;Because attackers want &lt;strong&gt;persistence&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;If the original password is changed, another credential may still provide access.&lt;/p&gt;

&lt;p&gt;This is why security teams don't ask only:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Was the password changed?”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;They ask:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“What other credentials or trust relationships were created?”&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h1&gt;
  
  
  Attack #4: The Secret You Accidentally Pushed
&lt;/h1&gt;

&lt;p&gt;This is probably one of the most common developer mistakes.&lt;/p&gt;

&lt;p&gt;Imagine writing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="kt"&gt;char&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;api_key&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;
    &lt;span class="s"&gt;"SUPER_SECRET_VALUE"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then committing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git add &lt;span class="nb"&gt;.&lt;/span&gt;
git commit &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"add API integration"&lt;/span&gt;
git push
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now the secret may exist in Git history.&lt;/p&gt;

&lt;p&gt;Deleting the line later doesn't necessarily erase the historical commit.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Commit 1
   |
   +-- source code

Commit 2
   |
   +-- API_KEY = SECRET

Commit 3
   |
   +-- API_KEY removed
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The developer sees:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Current code:
SECRET = gone
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But the repository history may still contain:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Commit 2:
SECRET = still present
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's why:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Removing a secret from the latest version is not the same as revoking the secret.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If a real credential is exposed, the important response is generally to &lt;strong&gt;revoke/rotate it&lt;/strong&gt;, then clean up the repository history where appropriate.&lt;/p&gt;




&lt;h1&gt;
  
  
  The Scale Is Bigger Than Most Developers Realize
&lt;/h1&gt;

&lt;p&gt;GitHub reported that more than &lt;strong&gt;39 million secrets were leaked across GitHub in 2024&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;That's an enormous number.&lt;/p&gt;

&lt;p&gt;And this explains why secret scanning and push protection exist.&lt;/p&gt;

&lt;p&gt;GitHub has also described push protection as a mechanism that can block commits when supported secrets are detected before they enter public repositories.&lt;/p&gt;

&lt;p&gt;The lesson isn't:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“GitHub is insecure.”&lt;/p&gt;
&lt;/blockquote&gt;

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

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Developers are part of the security boundary.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Your repository can be perfectly protected while you accidentally publish a cloud credential.&lt;/p&gt;




&lt;h1&gt;
  
  
  Attack #5: Attack the Supply Chain
&lt;/h1&gt;

&lt;p&gt;Here's where things become much more complicated.&lt;/p&gt;

&lt;p&gt;Your repository might be secure.&lt;/p&gt;

&lt;p&gt;Your password might be secure.&lt;/p&gt;

&lt;p&gt;Your server might be secure.&lt;/p&gt;

&lt;p&gt;But what about your dependencies?&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Your application
      |
      +---- dependency A
      |
      +---- dependency B
      |
      +---- dependency C
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dependency C
      |
      +---- dependency D
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now your application depends on software you didn't write.&lt;/p&gt;

&lt;p&gt;This creates a &lt;strong&gt;software supply-chain attack surface&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;GitHub has specifically documented repo-jacking as a supply-chain risk. A repository that has been renamed or transferred can potentially create problems for projects that reference it incorrectly. GitHub recommends pinning dependencies to specific commit IDs in relevant scenarios.&lt;/p&gt;

&lt;p&gt;The important idea is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Trust
  ↓
Repository
  ↓
Dependency
  ↓
Build system
  ↓
Production
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Every link matters.&lt;/p&gt;




&lt;h1&gt;
  
  
  Attack #6: A Vulnerability in the Platform
&lt;/h1&gt;

&lt;p&gt;Sometimes the target really is the platform itself.&lt;/p&gt;

&lt;p&gt;In December 2023, GitHub received a bug-bounty report describing a vulnerability that could allow access to environment variables from a production container.&lt;/p&gt;

&lt;p&gt;GitHub patched the issue the same day and said its investigation found no evidence that the vulnerability had previously been discovered or exploited.&lt;/p&gt;

&lt;p&gt;And in March 2026, GitHub disclosed a critical remote-code-execution vulnerability affecting multiple GitHub environments.&lt;/p&gt;

&lt;p&gt;GitHub said it validated the report, deployed a fix to GitHub.com in under two hours, and concluded its investigation with no evidence of exploitation.&lt;/p&gt;

&lt;p&gt;This is a completely different category:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Attacker
   |
   v
Vulnerability
   |
   v
Application
   |
   v
Execution
   |
   v
Potential privilege escalation
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is what people often imagine when they hear:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“GitHub got hacked.”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;But finding and exploiting a vulnerability is only one possible attack path.&lt;/p&gt;




&lt;h1&gt;
  
  
  The Most Important Security Concept: Trust Boundaries
&lt;/h1&gt;

&lt;p&gt;Let's simplify the whole problem.&lt;/p&gt;

&lt;p&gt;Imagine GitHub as:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;                    INTERNET
                       |
                       v
              ┌─────────────────┐
              │     GitHub      │
              └─────────────────┘
                 /     |      \
                /      |       \
               v       v        v
          Developers  OAuth   Actions
                      Apps
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Every arrow represents a &lt;strong&gt;trust relationship&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;And every trust relationship is an attack surface.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Developer
   |
   | credentials
   v
GitHub
   |
   | token
   v
OAuth application
   |
   | permissions
   v
Repository
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If any link is compromised, the attacker may gain access to the next layer.&lt;/p&gt;

&lt;p&gt;This is why modern security engineering focuses heavily on:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;least privilege&lt;/li&gt;
&lt;li&gt;credential rotation&lt;/li&gt;
&lt;li&gt;short-lived credentials&lt;/li&gt;
&lt;li&gt;strong authentication&lt;/li&gt;
&lt;li&gt;audit logs&lt;/li&gt;
&lt;li&gt;secret scanning&lt;/li&gt;
&lt;li&gt;dependency pinning&lt;/li&gt;
&lt;li&gt;network isolation&lt;/li&gt;
&lt;li&gt;continuous monitoring&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  Why “Just Use 2FA” Isn't the Whole Answer
&lt;/h1&gt;

&lt;p&gt;2FA is important.&lt;/p&gt;

&lt;p&gt;But security isn't a single checkbox.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Password
    +
2FA
    +
OAuth token
    +
SSH key
    +
GitHub Actions
    +
Cloud credentials
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;An account can have strong login protection while another credential remains compromised.&lt;/p&gt;

&lt;p&gt;Security therefore becomes a lifecycle:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;IDENTITY
   ↓
AUTHENTICATION
   ↓
AUTHORIZATION
   ↓
CREDENTIALS
   ↓
ACTIVITY
   ↓
MONITORING
   ↓
REVOCATION
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Every stage matters.&lt;/p&gt;




&lt;h1&gt;
  
  
  Least Privilege Changes the Game
&lt;/h1&gt;

&lt;p&gt;Suppose an application only needs to read one repository.&lt;/p&gt;

&lt;p&gt;Bad design:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Application
    |
    +---- full organization access
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Better design:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Application
    |
    +---- read-only
    |
    +---- specific repository
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If that credential is stolen, the blast radius is smaller.&lt;/p&gt;

&lt;p&gt;This is the principle of:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Least privilege&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;GitHub introduced fine-grained personal access tokens specifically to provide more precise permissions and reduce the risk associated with compromised tokens.&lt;/p&gt;

&lt;p&gt;The question shouldn't be:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Can this application access the repository?”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;It should be:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“What is the minimum access this application needs?”&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h1&gt;
  
  
  Think Like a Security Engineer
&lt;/h1&gt;

&lt;p&gt;When you build software, don't ask only:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Does it work?
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;What happens if this credential leaks?

What happens if this user is compromised?

What happens if this dependency becomes malicious?

What happens if this OAuth token is stolen?

What happens if this server is compromised?

What happens if an attacker gets read access?

What happens if an attacker gets write access?

How do we detect it?

How do we revoke access?

How do we recover?
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Those questions are far more valuable than simply asking:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Is my application secure?”&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h1&gt;
  
  
  A Realistic Attack Chain
&lt;/h1&gt;

&lt;p&gt;Put everything together.&lt;/p&gt;

&lt;p&gt;A modern software attack could conceptually look like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;        PHISHING
           |
           v
    Developer account
           |
           v
     OAuth / PAT / SSH
           |
           v
     Private repository
           |
           v
       Secret found
           |
           v
     Cloud environment
           |
           v
     Production system
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice something important.&lt;/p&gt;

&lt;p&gt;The attacker didn't necessarily:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;break GitHub
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;They abused &lt;strong&gt;trust&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;That's the deeper lesson.&lt;/p&gt;




&lt;h1&gt;
  
  
  So, Was GitHub “Hacked”?
&lt;/h1&gt;

&lt;p&gt;The answer depends on what you mean by hacked.&lt;/p&gt;

&lt;p&gt;There have been:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;account-targeting attacks&lt;/li&gt;
&lt;li&gt;stolen-token campaigns&lt;/li&gt;
&lt;li&gt;phishing campaigns&lt;/li&gt;
&lt;li&gt;security vulnerabilities&lt;/li&gt;
&lt;li&gt;service incidents&lt;/li&gt;
&lt;li&gt;supply-chain risks&lt;/li&gt;
&lt;li&gt;credential exposure incidents&lt;/li&gt;
&lt;li&gt;attacks against GitHub Enterprise environments&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But these are not all the same thing.&lt;/p&gt;

&lt;p&gt;For example, in the 2022 OAuth-token incident, GitHub explicitly said it did not believe GitHub itself was compromised in the way people might normally imagine; attackers abused stolen tokens issued by third-party OAuth integrations.&lt;/p&gt;

&lt;p&gt;And in the 2026 RCE disclosure, GitHub reported that it fixed the vulnerability and found no evidence of exploitation.&lt;/p&gt;

&lt;p&gt;Precision matters.&lt;/p&gt;

&lt;p&gt;“GitHub was hacked” can hide the actual security lesson.&lt;/p&gt;




&lt;h1&gt;
  
  
  The Real Lesson
&lt;/h1&gt;

&lt;p&gt;The most dangerous misconception in cybersecurity is:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Attackers break systems.”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Often, attackers don't need to.&lt;/p&gt;

&lt;p&gt;They abuse what systems already trust.&lt;/p&gt;

&lt;p&gt;A stolen credential.&lt;/p&gt;

&lt;p&gt;A valid token.&lt;/p&gt;

&lt;p&gt;A compromised account.&lt;/p&gt;

&lt;p&gt;A vulnerable dependency.&lt;/p&gt;

&lt;p&gt;A leaked secret.&lt;/p&gt;

&lt;p&gt;An overly powerful service account.&lt;/p&gt;

&lt;p&gt;A trusted integration.&lt;/p&gt;

&lt;p&gt;That's modern security.&lt;/p&gt;

&lt;p&gt;The strongest system isn't necessarily the system with the biggest lock.&lt;/p&gt;

&lt;p&gt;It's the system where:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;credentials are limited
        +
permissions are limited
        +
secrets are protected
        +
dependencies are controlled
        +
activity is monitored
        +
compromise is detected
        +
access can be revoked
        +
systems can recover
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And that's the real reason GitHub security is interesting.&lt;/p&gt;

&lt;p&gt;GitHub isn't just a website where developers store code.&lt;/p&gt;

&lt;p&gt;It's a &lt;strong&gt;massive trust network connecting developers, identities, repositories, CI/CD systems, dependencies, cloud infrastructure, and production environments.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Attack the trust network—&lt;/p&gt;

&lt;p&gt;and you may not need to attack the website at all.&lt;/p&gt;




&lt;h2&gt;
  
  
  Final Thought
&lt;/h2&gt;

&lt;p&gt;The next time you run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git push
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;remember:&lt;/p&gt;

&lt;p&gt;You're not just uploading code.&lt;/p&gt;

&lt;p&gt;You're participating in a security system.&lt;/p&gt;

&lt;p&gt;Your repository has identities.&lt;/p&gt;

&lt;p&gt;Your identities have permissions.&lt;/p&gt;

&lt;p&gt;Your permissions have credentials.&lt;/p&gt;

&lt;p&gt;Your credentials have blast radius.&lt;/p&gt;

&lt;p&gt;And somewhere in that chain is the thing an attacker is looking for.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Security isn't about making one door impossible to break.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;It's about making sure that opening one door doesn't open the entire building.&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>github</category>
      <category>githubactions</category>
      <category>code</category>
      <category>productivity</category>
    </item>
    <item>
      <title>How to Build Your Own Filesystem From Scratch in C</title>
      <dc:creator>Farhad Rahimi Klie</dc:creator>
      <pubDate>Mon, 03 Aug 2026 11:51:09 +0000</pubDate>
      <link>https://dev.to/farhadrahimiklie/how-to-build-your-own-filesystem-from-scratch-in-c-2b7f</link>
      <guid>https://dev.to/farhadrahimiklie/how-to-build-your-own-filesystem-from-scratch-in-c-2b7f</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;Stop treating filesystems as magic. Build one yourself and understand how operating systems actually store data.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Most programmers use a filesystem every day.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="kt"&gt;FILE&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;fp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;fopen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"notes.txt"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"r"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;or&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;fd&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"file.txt"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;O_RDONLY&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But very few programmers know what happens after those function calls.&lt;/p&gt;

&lt;p&gt;Where is the file actually stored?&lt;/p&gt;

&lt;p&gt;How does the operating system know where its data begins?&lt;/p&gt;

&lt;p&gt;How does deleting a file free disk space?&lt;/p&gt;

&lt;p&gt;How does a filesystem survive a power failure?&lt;/p&gt;

&lt;p&gt;These questions are answered by one piece of software:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The filesystem.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In this article, we'll build one from scratch—not a toy with a single array in memory, but a real userspace filesystem stored inside a &lt;code&gt;disk.img&lt;/code&gt; file. By the end, you'll understand many of the same concepts used by Linux filesystems like ext2, ext3, and ext4.&lt;/p&gt;




&lt;h1&gt;
  
  
  Why Build a Filesystem?
&lt;/h1&gt;

&lt;p&gt;Building a filesystem teaches far more than file storage.&lt;/p&gt;

&lt;p&gt;You'll learn about:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Disk layouts&lt;/li&gt;
&lt;li&gt;Binary file formats&lt;/li&gt;
&lt;li&gt;Metadata&lt;/li&gt;
&lt;li&gt;Block allocation&lt;/li&gt;
&lt;li&gt;Bitmaps&lt;/li&gt;
&lt;li&gt;Direct and indirect pointers&lt;/li&gt;
&lt;li&gt;File growth&lt;/li&gt;
&lt;li&gt;Directory structures&lt;/li&gt;
&lt;li&gt;Crash consistency&lt;/li&gt;
&lt;li&gt;C programming&lt;/li&gt;
&lt;li&gt;Systems programming&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It's one of the best projects for becoming a systems programmer.&lt;/p&gt;




&lt;h1&gt;
  
  
  What Is a Filesystem?
&lt;/h1&gt;

&lt;p&gt;A filesystem is software that organizes raw bytes on a storage device.&lt;/p&gt;

&lt;p&gt;Imagine you have a completely empty disk.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;+------------------------------------------------+
|                                                |
|             1 GB of Random Bytes               |
|                                                |
+------------------------------------------------+
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Without a filesystem, the operating system sees only bytes.&lt;/p&gt;

&lt;p&gt;It doesn't know:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;where files begin&lt;/li&gt;
&lt;li&gt;where files end&lt;/li&gt;
&lt;li&gt;which space is free&lt;/li&gt;
&lt;li&gt;what filenames exist&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The filesystem provides all of that information.&lt;/p&gt;




&lt;h1&gt;
  
  
  The Basic Idea
&lt;/h1&gt;

&lt;p&gt;Instead of treating the disk as one giant byte array, we divide it into blocks.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Disk

+------+------+------+------+------+------+
|Blk 0 |Blk 1 |Blk 2 |Blk 3 |Blk 4 | ... |
+------+------+------+------+------+------+
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A block is the smallest storage unit.&lt;/p&gt;

&lt;p&gt;Typical sizes are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;512 bytes&lt;/li&gt;
&lt;li&gt;1024 bytes&lt;/li&gt;
&lt;li&gt;2048 bytes&lt;/li&gt;
&lt;li&gt;4096 bytes&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Linux commonly uses &lt;strong&gt;4096-byte blocks&lt;/strong&gt;.&lt;/p&gt;




&lt;h1&gt;
  
  
  Our Project
&lt;/h1&gt;

&lt;p&gt;We'll build everything ourselves.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;disk.img

+-------------------------+
| Superblock              |
+-------------------------+
| Bitmap                  |
+-------------------------+
| Inode Table             |
+-------------------------+
| Data Blocks             |
+-------------------------+
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Every modern filesystem has something similar.&lt;/p&gt;




&lt;h1&gt;
  
  
  Step 1 — Create a Virtual Disk
&lt;/h1&gt;

&lt;p&gt;Instead of modifying a real hard drive, we'll use a normal file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;disk.img
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Think of it as pretending this file is an SSD.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;disk.img

+------------------------------------------+
|                                          |
|             Raw Bytes                    |
|                                          |
+------------------------------------------+
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can open it using normal C functions.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="kt"&gt;FILE&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;disk&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;fopen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"disk.img"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"rb+"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;or&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;fd&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"disk.img"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;O_RDWR&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Every read and write will modify the virtual disk.&lt;/p&gt;




&lt;h1&gt;
  
  
  Step 2 — Design the Disk Layout
&lt;/h1&gt;

&lt;p&gt;Before writing code, always design the filesystem.&lt;/p&gt;

&lt;p&gt;Never start coding first.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Block 0
----------------
Superblock

Blocks 1-8
----------------
Bitmap

Blocks 9-40
----------------
Inode Table

Blocks 41+
----------------
File Data
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Everything begins with a good layout.&lt;/p&gt;




&lt;h1&gt;
  
  
  Step 3 — Superblock
&lt;/h1&gt;

&lt;p&gt;The superblock is the brain of the filesystem.&lt;/p&gt;

&lt;p&gt;It stores global information.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Superblock

Magic Number
Version
Block Size
Total Blocks
Free Blocks
Inode Count
Free Inodes
Bitmap Start
Inode Start
Data Start
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Whenever the filesystem mounts, it reads the superblock first.&lt;/p&gt;

&lt;p&gt;Without it, nothing else can be understood.&lt;/p&gt;




&lt;h1&gt;
  
  
  Step 4 — Blocks
&lt;/h1&gt;

&lt;p&gt;Instead of storing files continuously, we store them in blocks.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;File

Hello World!

Stored as

Block 90
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A larger file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Block 90
Block 91
Block 92
Block 93
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Large files simply occupy more blocks.&lt;/p&gt;




&lt;h1&gt;
  
  
  Step 5 — Free Space Management
&lt;/h1&gt;

&lt;p&gt;How does the filesystem know which blocks are free?&lt;/p&gt;

&lt;p&gt;Using a bitmap.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Block Number

0 1 2 3 4 5 6 7

Bitmap

1 1 0 0 1 0 0 0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1 = Used
0 = Free
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Finding free space becomes easy.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Search bitmap

↓

00100000

↓

Found!

Allocate Block 2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This technique is used in ext2, ext3, ext4, FAT, and many other filesystems.&lt;/p&gt;




&lt;h1&gt;
  
  
  Step 6 — Inodes
&lt;/h1&gt;

&lt;p&gt;The inode is the heart of every Unix filesystem.&lt;/p&gt;

&lt;p&gt;It stores metadata—not the filename.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;inode

File Size

Permissions

Owner

Creation Time

Modified Time

Block Pointers
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice something missing?&lt;/p&gt;

&lt;p&gt;The filename.&lt;/p&gt;

&lt;p&gt;Linux stores filenames separately inside directories.&lt;/p&gt;




&lt;h1&gt;
  
  
  Step 7 — Direct Block Pointers
&lt;/h1&gt;

&lt;p&gt;Small files are easy.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;inode

Block 91

Block 92

Block 93

Block 94
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each pointer references one data block.&lt;/p&gt;

&lt;p&gt;Reading the file is straightforward.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Read inode

↓

Read block pointers

↓

Read data
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h1&gt;
  
  
  Step 8 — File Growth
&lt;/h1&gt;

&lt;p&gt;Eventually a file becomes larger.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Before

inode

91

92

93

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

&lt;/div&gt;



&lt;p&gt;Now write more data.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Filesystem

↓

Find Free Block

↓

Allocate

↓

Update Bitmap

↓

Update Inode

↓

Increase File Size
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Growing a file is simply allocating additional blocks and updating metadata.&lt;/p&gt;




&lt;h1&gt;
  
  
  Step 9 — Indirect Pointers
&lt;/h1&gt;

&lt;p&gt;Direct pointers eventually run out.&lt;/p&gt;

&lt;p&gt;Linux solves this with indirect blocks.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;inode

Direct

Direct

Direct

Indirect
        |
        v

+--------------------+
|101|102|103|104|...|
+--------------------+
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Instead of pointing to data, the inode points to another block containing many more block numbers.&lt;/p&gt;

&lt;p&gt;This allows files to grow into gigabytes or even terabytes.&lt;/p&gt;




&lt;h1&gt;
  
  
  Step 10 — Directories
&lt;/h1&gt;

&lt;p&gt;A directory is just another file.&lt;/p&gt;

&lt;p&gt;Instead of storing text, it stores mappings.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Filename

↓

Inode Number
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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;notes.txt

↓

inode 15

photo.png

↓

inode 42

movie.mp4

↓

inode 80
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The operating system first finds the inode, then reads the file.&lt;/p&gt;




&lt;h1&gt;
  
  
  Step 11 — Reading a File
&lt;/h1&gt;

&lt;p&gt;The process is surprisingly simple.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Open File

↓

Find Directory Entry

↓

Get Inode Number

↓

Read Inode

↓

Read Block Pointers

↓

Read Data Blocks

↓

Return Bytes
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This sequence happens every time you open a file.&lt;/p&gt;




&lt;h1&gt;
  
  
  Step 12 — Deleting a File
&lt;/h1&gt;

&lt;p&gt;Deleting does &lt;strong&gt;not&lt;/strong&gt; erase the data immediately.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Remove Directory Entry

↓

Free Blocks in Bitmap

↓

Free Inode

↓

Mark Space Available
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The old bytes often remain until overwritten.&lt;/p&gt;




&lt;h1&gt;
  
  
  Step 13 — Formatting the Filesystem
&lt;/h1&gt;

&lt;p&gt;Before using the disk, it must be formatted.&lt;/p&gt;

&lt;p&gt;Formatting means:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create the superblock&lt;/li&gt;
&lt;li&gt;Initialize the bitmap&lt;/li&gt;
&lt;li&gt;Create empty inode table&lt;/li&gt;
&lt;li&gt;Reserve metadata blocks&lt;/li&gt;
&lt;li&gt;Mark remaining blocks as free&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After formatting, the filesystem is ready.&lt;/p&gt;




&lt;h1&gt;
  
  
  Step 14 — Features to Add Later
&lt;/h1&gt;

&lt;p&gt;Once the core filesystem works, you can implement advanced features.&lt;/p&gt;

&lt;h3&gt;
  
  
  Symbolic Links
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;myfile

↓

inode

↓

Target Path
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Hard Links
&lt;/h3&gt;

&lt;p&gt;Multiple filenames pointing to the same inode.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fileA

↓

inode 12

↑

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

&lt;/div&gt;






&lt;h3&gt;
  
  
  Journaling
&lt;/h3&gt;

&lt;p&gt;Protects against crashes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Write Journal

↓

Write Real Data

↓

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

&lt;/div&gt;



&lt;p&gt;If the system crashes, unfinished operations can be replayed safely.&lt;/p&gt;




&lt;h3&gt;
  
  
  Permissions
&lt;/h3&gt;

&lt;p&gt;Store Unix permissions.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rwxr-xr-x
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Timestamps
&lt;/h3&gt;

&lt;p&gt;Maintain:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Creation time&lt;/li&gt;
&lt;li&gt;Modification time&lt;/li&gt;
&lt;li&gt;Access time&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Nested Directories
&lt;/h3&gt;

&lt;p&gt;Support structures like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/

home/

home/user/

home/user/docs/

home/user/docs/file.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h1&gt;
  
  
  Suggested Development Order
&lt;/h1&gt;

&lt;p&gt;Don't try to build everything at once.&lt;/p&gt;

&lt;p&gt;Follow this roadmap:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create &lt;code&gt;disk.img&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Define block size&lt;/li&gt;
&lt;li&gt;Implement disk read/write functions&lt;/li&gt;
&lt;li&gt;Create the superblock&lt;/li&gt;
&lt;li&gt;Implement bitmap-based free space management&lt;/li&gt;
&lt;li&gt;Build the inode table&lt;/li&gt;
&lt;li&gt;Create files&lt;/li&gt;
&lt;li&gt;Read files&lt;/li&gt;
&lt;li&gt;Write files&lt;/li&gt;
&lt;li&gt;Delete files&lt;/li&gt;
&lt;li&gt;Implement file growth&lt;/li&gt;
&lt;li&gt;Add directories&lt;/li&gt;
&lt;li&gt;Support nested directories&lt;/li&gt;
&lt;li&gt;Add indirect pointers&lt;/li&gt;
&lt;li&gt;Add journaling&lt;/li&gt;
&lt;li&gt;Add caching&lt;/li&gt;
&lt;li&gt;Optimize performance&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Each milestone builds on the previous one, making debugging much easier.&lt;/p&gt;




&lt;h1&gt;
  
  
  Final Thoughts
&lt;/h1&gt;

&lt;p&gt;Building a filesystem is one of the most rewarding systems programming projects you can undertake. It combines low-level C programming, binary data structures, memory management, and operating system concepts into a single, practical project.&lt;/p&gt;

&lt;p&gt;You'll stop thinking of files as mysterious objects managed by the OS and start seeing them for what they really are: carefully organized blocks of bytes, tracked by metadata and allocation structures.&lt;/p&gt;

&lt;p&gt;If you can build a filesystem from scratch, you'll gain a much deeper understanding of how Linux works internally—and you'll develop the skills needed for advanced areas like kernel development, storage engines, databases, embedded systems, and operating system design.&lt;/p&gt;

&lt;p&gt;Every byte on a disk has a purpose. Your job as a filesystem developer is to decide what that purpose should be.&lt;/p&gt;

</description>
      <category>filesystem</category>
      <category>c</category>
      <category>programming</category>
      <category>disk</category>
    </item>
    <item>
      <title>How to Become a System Programmer in 2026</title>
      <dc:creator>Farhad Rahimi Klie</dc:creator>
      <pubDate>Sun, 02 Aug 2026 10:57:47 +0000</pubDate>
      <link>https://dev.to/farhadrahimiklie/how-to-become-a-system-programmer-in-2026-ilg</link>
      <guid>https://dev.to/farhadrahimiklie/how-to-become-a-system-programmer-in-2026-ilg</guid>
      <description>&lt;p&gt;&lt;em&gt;Stop chasing frameworks. Start understanding the machine.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Most developers spend years learning frameworks, libraries, and APIs. Yet very few understand what actually happens after they press &lt;strong&gt;Compile&lt;/strong&gt; or &lt;strong&gt;Run&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;System programmers are different.&lt;/p&gt;

&lt;p&gt;They build operating systems, databases, compilers, virtual machines, device drivers, networking software, embedded systems, hypervisors, game engines, and high-performance applications. They work closer to the hardware than almost any other software engineer.&lt;/p&gt;

&lt;p&gt;In 2026, as AI generates more application code than ever before, developers who understand computers at the lowest levels are becoming increasingly valuable.&lt;/p&gt;

&lt;p&gt;This article provides a practical roadmap to becoming a system programmer.&lt;/p&gt;




&lt;h1&gt;
  
  
  What Is System Programming?
&lt;/h1&gt;

&lt;p&gt;System programming is the art of writing software that interacts directly with the operating system or hardware.&lt;/p&gt;

&lt;p&gt;Instead of building websites or mobile apps, system programmers create software such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Operating systems&lt;/li&gt;
&lt;li&gt;Kernels&lt;/li&gt;
&lt;li&gt;Device drivers&lt;/li&gt;
&lt;li&gt;File systems&lt;/li&gt;
&lt;li&gt;Compilers&lt;/li&gt;
&lt;li&gt;Linkers&lt;/li&gt;
&lt;li&gt;Assemblers&lt;/li&gt;
&lt;li&gt;Database engines&lt;/li&gt;
&lt;li&gt;Virtual machines&lt;/li&gt;
&lt;li&gt;Hypervisors&lt;/li&gt;
&lt;li&gt;Networking software&lt;/li&gt;
&lt;li&gt;Embedded firmware&lt;/li&gt;
&lt;li&gt;Performance-critical libraries&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These programs manage computer resources and provide services that application software depends on.&lt;/p&gt;




&lt;h1&gt;
  
  
  Why System Programming Matters More Than Ever
&lt;/h1&gt;

&lt;p&gt;Many developers worry that AI will replace programmers.&lt;/p&gt;

&lt;p&gt;AI can generate CRUD applications.&lt;/p&gt;

&lt;p&gt;AI can build websites.&lt;/p&gt;

&lt;p&gt;AI can write boilerplate code.&lt;/p&gt;

&lt;p&gt;But AI still struggles with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Operating system internals&lt;/li&gt;
&lt;li&gt;CPU architecture&lt;/li&gt;
&lt;li&gt;Memory management&lt;/li&gt;
&lt;li&gt;Performance optimization&lt;/li&gt;
&lt;li&gt;Lock-free algorithms&lt;/li&gt;
&lt;li&gt;Kernel development&lt;/li&gt;
&lt;li&gt;Compiler optimization&lt;/li&gt;
&lt;li&gt;Hardware communication&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These require deep understanding rather than memorization.&lt;/p&gt;

&lt;p&gt;The closer you are to the hardware, the harder you are to replace.&lt;/p&gt;




&lt;h1&gt;
  
  
  Step 1 — Master the C Language
&lt;/h1&gt;

&lt;p&gt;If system programming has a native language, it is C.&lt;/p&gt;

&lt;p&gt;Learn:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Variables&lt;/li&gt;
&lt;li&gt;Pointers&lt;/li&gt;
&lt;li&gt;Arrays&lt;/li&gt;
&lt;li&gt;Structures&lt;/li&gt;
&lt;li&gt;Memory layout&lt;/li&gt;
&lt;li&gt;Bitwise operators&lt;/li&gt;
&lt;li&gt;Function pointers&lt;/li&gt;
&lt;li&gt;Dynamic memory allocation&lt;/li&gt;
&lt;li&gt;Header files&lt;/li&gt;
&lt;li&gt;Build systems&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Don't just memorize syntax.&lt;/p&gt;

&lt;p&gt;Understand what every line becomes in memory.&lt;/p&gt;

&lt;p&gt;You should know exactly why this works:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;ptr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;malloc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;sizeof&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Not just that it works.&lt;/p&gt;




&lt;h1&gt;
  
  
  Step 2 — Learn Computer Architecture
&lt;/h1&gt;

&lt;p&gt;A system programmer must understand the machine.&lt;/p&gt;

&lt;p&gt;Study:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;CPU execution&lt;/li&gt;
&lt;li&gt;Registers&lt;/li&gt;
&lt;li&gt;Cache hierarchy&lt;/li&gt;
&lt;li&gt;Virtual memory&lt;/li&gt;
&lt;li&gt;Paging&lt;/li&gt;
&lt;li&gt;Stack vs Heap&lt;/li&gt;
&lt;li&gt;Calling conventions&lt;/li&gt;
&lt;li&gt;Assembly language&lt;/li&gt;
&lt;li&gt;Interrupts&lt;/li&gt;
&lt;li&gt;Pipelines&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Books worth reading:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Computer Systems: A Programmer's Perspective&lt;/li&gt;
&lt;li&gt;Computer Organization and Design&lt;/li&gt;
&lt;li&gt;Modern Operating Systems&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  Step 3 — Become a Linux Power User
&lt;/h1&gt;

&lt;p&gt;Windows is fine.&lt;/p&gt;

&lt;p&gt;Linux is essential.&lt;/p&gt;

&lt;p&gt;Spend every day inside Linux.&lt;/p&gt;

&lt;p&gt;Learn:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Shell scripting&lt;/li&gt;
&lt;li&gt;Bash&lt;/li&gt;
&lt;li&gt;File permissions&lt;/li&gt;
&lt;li&gt;Processes&lt;/li&gt;
&lt;li&gt;Signals&lt;/li&gt;
&lt;li&gt;Pipes&lt;/li&gt;
&lt;li&gt;Redirection&lt;/li&gt;
&lt;li&gt;ELF binaries&lt;/li&gt;
&lt;li&gt;Package managers&lt;/li&gt;
&lt;li&gt;System services&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Use the terminal constantly.&lt;/p&gt;

&lt;p&gt;If you can solve a problem without opening a GUI, do it.&lt;/p&gt;




&lt;h1&gt;
  
  
  Step 4 — Learn POSIX System Calls
&lt;/h1&gt;

&lt;p&gt;Applications eventually communicate with the kernel through system calls.&lt;/p&gt;

&lt;p&gt;Start with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;open()&lt;/li&gt;
&lt;li&gt;close()&lt;/li&gt;
&lt;li&gt;read()&lt;/li&gt;
&lt;li&gt;write()&lt;/li&gt;
&lt;li&gt;lseek()&lt;/li&gt;
&lt;li&gt;mmap()&lt;/li&gt;
&lt;li&gt;fork()&lt;/li&gt;
&lt;li&gt;execve()&lt;/li&gt;
&lt;li&gt;wait()&lt;/li&gt;
&lt;li&gt;pipe()&lt;/li&gt;
&lt;li&gt;dup()&lt;/li&gt;
&lt;li&gt;socket()&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Understand:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;File descriptors&lt;/li&gt;
&lt;li&gt;Buffers&lt;/li&gt;
&lt;li&gt;Kernel transitions&lt;/li&gt;
&lt;li&gt;User space vs Kernel space&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  Step 5 — Understand Memory
&lt;/h1&gt;

&lt;p&gt;Memory separates beginner programmers from professionals.&lt;/p&gt;

&lt;p&gt;Study:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Stack&lt;/li&gt;
&lt;li&gt;Heap&lt;/li&gt;
&lt;li&gt;Static memory&lt;/li&gt;
&lt;li&gt;Memory alignment&lt;/li&gt;
&lt;li&gt;Fragmentation&lt;/li&gt;
&lt;li&gt;malloc()&lt;/li&gt;
&lt;li&gt;calloc()&lt;/li&gt;
&lt;li&gt;realloc()&lt;/li&gt;
&lt;li&gt;free()&lt;/li&gt;
&lt;li&gt;Memory leaks&lt;/li&gt;
&lt;li&gt;Buffer overflows&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Tools to master:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Valgrind&lt;/li&gt;
&lt;li&gt;AddressSanitizer&lt;/li&gt;
&lt;li&gt;GDB&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  Step 6 — Learn Data Structures From Scratch
&lt;/h1&gt;

&lt;p&gt;Don't rely on library implementations.&lt;/p&gt;

&lt;p&gt;Implement yourself:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Dynamic Arrays&lt;/li&gt;
&lt;li&gt;Linked Lists&lt;/li&gt;
&lt;li&gt;Stacks&lt;/li&gt;
&lt;li&gt;Queues&lt;/li&gt;
&lt;li&gt;Hash Tables&lt;/li&gt;
&lt;li&gt;Binary Trees&lt;/li&gt;
&lt;li&gt;AVL Trees&lt;/li&gt;
&lt;li&gt;Red-Black Trees&lt;/li&gt;
&lt;li&gt;Heaps&lt;/li&gt;
&lt;li&gt;Tries&lt;/li&gt;
&lt;li&gt;Skip Lists&lt;/li&gt;
&lt;li&gt;Graphs&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Then optimize them.&lt;/p&gt;

&lt;p&gt;Measure their performance.&lt;/p&gt;




&lt;h1&gt;
  
  
  Step 7 — Study Operating System Internals
&lt;/h1&gt;

&lt;p&gt;Every system programmer should know how an operating system works.&lt;/p&gt;

&lt;p&gt;Topics include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Process scheduling&lt;/li&gt;
&lt;li&gt;Context switching&lt;/li&gt;
&lt;li&gt;Virtual memory&lt;/li&gt;
&lt;li&gt;File systems&lt;/li&gt;
&lt;li&gt;Kernel architecture&lt;/li&gt;
&lt;li&gt;Synchronization&lt;/li&gt;
&lt;li&gt;Deadlocks&lt;/li&gt;
&lt;li&gt;IPC&lt;/li&gt;
&lt;li&gt;Threads&lt;/li&gt;
&lt;li&gt;Scheduling algorithms&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Read source code.&lt;/p&gt;

&lt;p&gt;Linux is one of the greatest learning resources available.&lt;/p&gt;




&lt;h1&gt;
  
  
  Step 8 — Learn Networking
&lt;/h1&gt;

&lt;p&gt;Computers rarely work alone.&lt;/p&gt;

&lt;p&gt;Study:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;TCP/IP&lt;/li&gt;
&lt;li&gt;UDP&lt;/li&gt;
&lt;li&gt;DNS&lt;/li&gt;
&lt;li&gt;HTTP&lt;/li&gt;
&lt;li&gt;HTTPS&lt;/li&gt;
&lt;li&gt;Routing&lt;/li&gt;
&lt;li&gt;Sockets&lt;/li&gt;
&lt;li&gt;Epoll&lt;/li&gt;
&lt;li&gt;Poll&lt;/li&gt;
&lt;li&gt;Select&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Build:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;HTTP server&lt;/li&gt;
&lt;li&gt;Chat server&lt;/li&gt;
&lt;li&gt;File server&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  Step 9 — Learn Debugging
&lt;/h1&gt;

&lt;p&gt;Professional programmers spend less time writing code than debugging it.&lt;/p&gt;

&lt;p&gt;Master:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;GDB&lt;/li&gt;
&lt;li&gt;strace&lt;/li&gt;
&lt;li&gt;ltrace&lt;/li&gt;
&lt;li&gt;perf&lt;/li&gt;
&lt;li&gt;objdump&lt;/li&gt;
&lt;li&gt;nm&lt;/li&gt;
&lt;li&gt;readelf&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Learn to inspect:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Memory&lt;/li&gt;
&lt;li&gt;Registers&lt;/li&gt;
&lt;li&gt;Stack frames&lt;/li&gt;
&lt;li&gt;Assembly&lt;/li&gt;
&lt;li&gt;Core dumps&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  Step 10 — Read Source Code Every Day
&lt;/h1&gt;

&lt;p&gt;The fastest way to improve is reading production-quality code.&lt;/p&gt;

&lt;p&gt;Great projects include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Linux Kernel&lt;/li&gt;
&lt;li&gt;Git&lt;/li&gt;
&lt;li&gt;SQLite&lt;/li&gt;
&lt;li&gt;Redis&lt;/li&gt;
&lt;li&gt;musl libc&lt;/li&gt;
&lt;li&gt;BusyBox&lt;/li&gt;
&lt;li&gt;Vim&lt;/li&gt;
&lt;li&gt;Nginx&lt;/li&gt;
&lt;li&gt;PostgreSQL&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Professional programmers read code more often than they write it.&lt;/p&gt;




&lt;h1&gt;
  
  
  Step 11 — Build Real Projects
&lt;/h1&gt;

&lt;p&gt;Projects teach lessons tutorials cannot.&lt;/p&gt;

&lt;p&gt;Ideas:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Mini Shell&lt;/li&gt;
&lt;li&gt;Memory Allocator&lt;/li&gt;
&lt;li&gt;Text Editor&lt;/li&gt;
&lt;li&gt;HTTP Server&lt;/li&gt;
&lt;li&gt;File System&lt;/li&gt;
&lt;li&gt;Thread Pool&lt;/li&gt;
&lt;li&gt;Skip List Library&lt;/li&gt;
&lt;li&gt;JSON Parser&lt;/li&gt;
&lt;li&gt;Compiler&lt;/li&gt;
&lt;li&gt;Virtual Machine&lt;/li&gt;
&lt;li&gt;Toy Operating System&lt;/li&gt;
&lt;li&gt;Custom malloc()&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each project exposes new challenges.&lt;/p&gt;




&lt;h1&gt;
  
  
  Step 12 — Learn Performance Engineering
&lt;/h1&gt;

&lt;p&gt;Fast software wins.&lt;/p&gt;

&lt;p&gt;Understand:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Cache locality&lt;/li&gt;
&lt;li&gt;Branch prediction&lt;/li&gt;
&lt;li&gt;SIMD&lt;/li&gt;
&lt;li&gt;Compiler optimization&lt;/li&gt;
&lt;li&gt;False sharing&lt;/li&gt;
&lt;li&gt;Memory bandwidth&lt;/li&gt;
&lt;li&gt;CPU profiling&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Benchmark everything.&lt;/p&gt;

&lt;p&gt;Never assume.&lt;/p&gt;

&lt;p&gt;Measure.&lt;/p&gt;




&lt;h1&gt;
  
  
  Step 13 — Learn Assembly
&lt;/h1&gt;

&lt;p&gt;You don't need to become an assembly expert.&lt;/p&gt;

&lt;p&gt;But you should be able to read it.&lt;/p&gt;

&lt;p&gt;Learn:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;x86-64&lt;/li&gt;
&lt;li&gt;ARM64&lt;/li&gt;
&lt;li&gt;Calling conventions&lt;/li&gt;
&lt;li&gt;Stack frames&lt;/li&gt;
&lt;li&gt;Registers&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Compile C programs with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;gcc &lt;span class="nt"&gt;-S&lt;/span&gt; program.c
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then compare your C code with the generated assembly.&lt;/p&gt;




&lt;h1&gt;
  
  
  Step 14 — Learn How Compilers Work
&lt;/h1&gt;

&lt;p&gt;Compilers transform human-readable code into machine instructions.&lt;/p&gt;

&lt;p&gt;Study:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Lexical analysis&lt;/li&gt;
&lt;li&gt;Parsing&lt;/li&gt;
&lt;li&gt;AST&lt;/li&gt;
&lt;li&gt;Semantic analysis&lt;/li&gt;
&lt;li&gt;Intermediate Representation (IR)&lt;/li&gt;
&lt;li&gt;Optimization&lt;/li&gt;
&lt;li&gt;Code generation&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Building a tiny compiler will change the way you write code forever.&lt;/p&gt;




&lt;h1&gt;
  
  
  Step 15 — Never Stop Building
&lt;/h1&gt;

&lt;p&gt;Knowledge without projects fades quickly.&lt;/p&gt;

&lt;p&gt;Build something every month.&lt;/p&gt;

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

&lt;ul&gt;
&lt;li&gt;Shell&lt;/li&gt;
&lt;li&gt;Database&lt;/li&gt;
&lt;li&gt;Cache&lt;/li&gt;
&lt;li&gt;Compiler&lt;/li&gt;
&lt;li&gt;Kernel module&lt;/li&gt;
&lt;li&gt;TCP server&lt;/li&gt;
&lt;li&gt;Memory allocator&lt;/li&gt;
&lt;li&gt;Scheduler simulator&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Experience compounds.&lt;/p&gt;




&lt;h1&gt;
  
  
  A Recommended Learning Roadmap
&lt;/h1&gt;

&lt;h3&gt;
  
  
  Beginner (0–3 Months)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;C&lt;/li&gt;
&lt;li&gt;Linux&lt;/li&gt;
&lt;li&gt;Git&lt;/li&gt;
&lt;li&gt;Bash&lt;/li&gt;
&lt;li&gt;Makefiles&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Intermediate (3–9 Months)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Data Structures&lt;/li&gt;
&lt;li&gt;Pointers&lt;/li&gt;
&lt;li&gt;Memory&lt;/li&gt;
&lt;li&gt;System Calls&lt;/li&gt;
&lt;li&gt;Debugging&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Advanced (9–18 Months)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Operating Systems&lt;/li&gt;
&lt;li&gt;Networking&lt;/li&gt;
&lt;li&gt;Compilers&lt;/li&gt;
&lt;li&gt;Concurrency&lt;/li&gt;
&lt;li&gt;Performance Optimization&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Expert (18+ Months)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Kernel Development&lt;/li&gt;
&lt;li&gt;Database Internals&lt;/li&gt;
&lt;li&gt;Distributed Systems&lt;/li&gt;
&lt;li&gt;Virtual Machines&lt;/li&gt;
&lt;li&gt;Embedded Systems&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  Final Thoughts
&lt;/h1&gt;

&lt;p&gt;System programming isn't the easiest path—but it's one of the most rewarding.&lt;/p&gt;

&lt;p&gt;It teaches you &lt;strong&gt;how computers actually work&lt;/strong&gt;, not just how to use them. Every layer you master—from pointers and memory management to kernels and compilers—makes you a stronger engineer.&lt;/p&gt;

&lt;p&gt;Frameworks will evolve. Languages will rise and fall. AI will continue to automate routine coding.&lt;/p&gt;

&lt;p&gt;But developers who understand operating systems, hardware, performance, and low-level software will continue to solve the hardest engineering problems.&lt;/p&gt;

&lt;p&gt;Don't aim to become someone who can simply write code.&lt;/p&gt;

&lt;p&gt;Aim to become someone who understands the machine.&lt;/p&gt;

&lt;p&gt;That's what separates a programmer from a &lt;strong&gt;system programmer&lt;/strong&gt;.&lt;/p&gt;

</description>
      <category>systemprogrammer</category>
      <category>terminal</category>
      <category>code</category>
      <category>productivity</category>
    </item>
    <item>
      <title>How to Read Linux Man Pages Like a Professional Developer</title>
      <dc:creator>Farhad Rahimi Klie</dc:creator>
      <pubDate>Fri, 17 Jul 2026 11:02:29 +0000</pubDate>
      <link>https://dev.to/farhadrahimiklie/how-to-read-linux-man-pages-like-a-professional-developer-3plb</link>
      <guid>https://dev.to/farhadrahimiklie/how-to-read-linux-man-pages-like-a-professional-developer-3plb</guid>
      <description>&lt;p&gt;&lt;em&gt;Stop searching Google for every Linux command. Learn how to read the official documentation that Linux developers use every day.&lt;/em&gt;&lt;/p&gt;




&lt;p&gt;If you've ever typed:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;and immediately closed it because it looked confusing...&lt;/p&gt;

&lt;p&gt;You're not alone.&lt;/p&gt;

&lt;p&gt;Many beginners think Linux man pages are difficult, outdated, or only for advanced developers.&lt;/p&gt;

&lt;p&gt;The truth is completely different.&lt;/p&gt;

&lt;p&gt;Professional Linux developers, system administrators, DevOps engineers, and C programmers read man pages every single day.&lt;/p&gt;

&lt;p&gt;Learning to read them properly is one of the best skills you can develop.&lt;/p&gt;

&lt;p&gt;After reading this guide you'll know:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What a man page actually is&lt;/li&gt;
&lt;li&gt;Why man pages exist&lt;/li&gt;
&lt;li&gt;How they're organized&lt;/li&gt;
&lt;li&gt;How to navigate efficiently&lt;/li&gt;
&lt;li&gt;How to search inside them&lt;/li&gt;
&lt;li&gt;How to understand the syntax&lt;/li&gt;
&lt;li&gt;How professionals read documentation quickly&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let's begin.&lt;/p&gt;




&lt;h1&gt;
  
  
  What Is a Linux Man Page?
&lt;/h1&gt;

&lt;p&gt;&lt;strong&gt;Man&lt;/strong&gt; stands for &lt;strong&gt;Manual&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;A man page is the official documentation for a Linux command, system call, library function, configuration file, or programming interface.&lt;/p&gt;

&lt;p&gt;Instead of searching random websites, Linux provides documentation directly on your computer.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;man &lt;span class="nb"&gt;cp&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;opens the complete manual for the &lt;code&gt;cp&lt;/code&gt; command.&lt;/p&gt;

&lt;p&gt;Think of it as an offline encyclopedia built into Linux.&lt;/p&gt;




&lt;h1&gt;
  
  
  Why Were Man Pages Created?
&lt;/h1&gt;

&lt;p&gt;Linux contains thousands of commands.&lt;/p&gt;

&lt;p&gt;Nobody can remember every option.&lt;/p&gt;

&lt;p&gt;Instead of memorizing everything, developers simply read the documentation whenever they need it.&lt;/p&gt;

&lt;p&gt;Man pages are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Official&lt;/li&gt;
&lt;li&gt;Accurate&lt;/li&gt;
&lt;li&gt;Installed locally&lt;/li&gt;
&lt;li&gt;Available without Internet&lt;/li&gt;
&lt;li&gt;Updated with software packages&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This makes them one of the most reliable documentation sources available.&lt;/p&gt;




&lt;h1&gt;
  
  
  What Can You Find in Man Pages?
&lt;/h1&gt;

&lt;p&gt;Man pages aren't only for commands.&lt;/p&gt;

&lt;p&gt;They also document:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Linux commands&lt;/li&gt;
&lt;li&gt;C library functions&lt;/li&gt;
&lt;li&gt;System calls&lt;/li&gt;
&lt;li&gt;Configuration files&lt;/li&gt;
&lt;li&gt;Device files&lt;/li&gt;
&lt;li&gt;File formats&lt;/li&gt;
&lt;li&gt;Games&lt;/li&gt;
&lt;li&gt;Administration commands&lt;/li&gt;
&lt;/ul&gt;

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

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

&lt;/div&gt;



&lt;p&gt;Documentation for &lt;code&gt;ls&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;man &lt;span class="nb"&gt;printf&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Documentation for the shell version of &lt;code&gt;printf&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;man 3 &lt;span class="nb"&gt;printf&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Documentation for the C library function.&lt;/p&gt;




&lt;h1&gt;
  
  
  Understanding Man Sections
&lt;/h1&gt;

&lt;p&gt;Linux organizes documentation into sections.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Section&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;User Commands&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;System Calls&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;Library Functions (C)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;Device Files&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;td&gt;File Formats&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;6&lt;/td&gt;
&lt;td&gt;Games&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;7&lt;/td&gt;
&lt;td&gt;Miscellaneous&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;8&lt;/td&gt;
&lt;td&gt;System Administration&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;man 2 open
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Shows the Linux system call.&lt;/p&gt;

&lt;p&gt;While&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;man 3 open
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;may show a library function if one exists.&lt;/p&gt;

&lt;p&gt;This distinction is especially important for C programmers.&lt;/p&gt;




&lt;h1&gt;
  
  
  Opening a Man Page
&lt;/h1&gt;

&lt;p&gt;Simply type:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;man &lt;span class="nb"&gt;command&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;man &lt;span class="nb"&gt;grep&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Linux opens the manual using a pager called &lt;strong&gt;less&lt;/strong&gt;.&lt;/p&gt;




&lt;h1&gt;
  
  
  The Basic Structure of Every Man Page
&lt;/h1&gt;

&lt;p&gt;Although every page is different, most follow the same structure.&lt;/p&gt;




&lt;h2&gt;
  
  
  NAME
&lt;/h2&gt;

&lt;p&gt;The command name and a short description.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;grep - print lines matching patterns
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Always read this first.&lt;/p&gt;




&lt;h2&gt;
  
  
  SYNOPSIS
&lt;/h2&gt;

&lt;p&gt;Shows the command syntax.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;grep [OPTION]... PATTERN [FILE]...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This line tells you how to use the command.&lt;/p&gt;

&lt;p&gt;Let's decode it.&lt;/p&gt;




&lt;h3&gt;
  
  
  Square Brackets
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[OPTION]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Means optional.&lt;/p&gt;

&lt;p&gt;You may include it or not.&lt;/p&gt;




&lt;h3&gt;
  
  
  Three Dots (...)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[FILE]...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Means multiple values are allowed.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;grep &lt;/span&gt;hello file1 file2 file3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Uppercase Words
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;FILE
PATTERN
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These are placeholders.&lt;/p&gt;

&lt;p&gt;Replace them with your own values.&lt;/p&gt;




&lt;h3&gt;
  
  
  Vertical Bar
&lt;/h3&gt;

&lt;p&gt;Sometimes you'll see&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;A | B
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Choose one.&lt;/p&gt;

&lt;p&gt;Not both.&lt;/p&gt;




&lt;h1&gt;
  
  
  DESCRIPTION
&lt;/h1&gt;

&lt;p&gt;This explains what the command actually does.&lt;/p&gt;

&lt;p&gt;Don't skip it.&lt;/p&gt;

&lt;p&gt;Professionals usually read this section before anything else.&lt;/p&gt;




&lt;h1&gt;
  
  
  OPTIONS
&lt;/h1&gt;

&lt;p&gt;This is where you'll spend most of your time.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;-i
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Ignore case.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;-r
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Recursive search.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;-v
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Invert match.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-ri&lt;/span&gt; hello project/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Read each option carefully.&lt;/p&gt;




&lt;h1&gt;
  
  
  EXAMPLES
&lt;/h1&gt;

&lt;p&gt;Some man pages include examples.&lt;/p&gt;

&lt;p&gt;Unfortunately many don't.&lt;/p&gt;

&lt;p&gt;That's why understanding the syntax is important.&lt;/p&gt;




&lt;h1&gt;
  
  
  EXIT STATUS
&lt;/h1&gt;

&lt;p&gt;Commands return an exit code.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Success.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;General failure.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Specific error.&lt;/p&gt;

&lt;p&gt;This is very useful when writing shell scripts.&lt;/p&gt;




&lt;h1&gt;
  
  
  FILES
&lt;/h1&gt;

&lt;p&gt;Shows which files the command uses.&lt;/p&gt;

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

&lt;p&gt;Configuration files.&lt;/p&gt;

&lt;p&gt;Cache files.&lt;/p&gt;

&lt;p&gt;Database files.&lt;/p&gt;

&lt;p&gt;Runtime files.&lt;/p&gt;




&lt;h1&gt;
  
  
  ENVIRONMENT
&lt;/h1&gt;

&lt;p&gt;Lists environment variables that affect the command.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PATH
HOME
LANG
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h1&gt;
  
  
  SEE ALSO
&lt;/h1&gt;

&lt;p&gt;Perhaps the most overlooked section.&lt;/p&gt;

&lt;p&gt;Suppose you're reading:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;man &lt;span class="nb"&gt;grep&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At the bottom you'll find related commands such as:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sed
awk
find
regex
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is an excellent way to discover new tools.&lt;/p&gt;




&lt;h1&gt;
  
  
  How to Navigate Inside a Man Page
&lt;/h1&gt;

&lt;p&gt;Once opened, use these keys.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Key&lt;/th&gt;
&lt;th&gt;Action&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Space&lt;/td&gt;
&lt;td&gt;Next page&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;b&lt;/td&gt;
&lt;td&gt;Previous page&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Enter&lt;/td&gt;
&lt;td&gt;Next line&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;g&lt;/td&gt;
&lt;td&gt;Top of document&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;G&lt;/td&gt;
&lt;td&gt;Bottom of document&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;q&lt;/td&gt;
&lt;td&gt;Quit&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;h&lt;/td&gt;
&lt;td&gt;Help&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;These few shortcuts are enough for daily use.&lt;/p&gt;




&lt;h1&gt;
  
  
  Searching Inside a Man Page
&lt;/h1&gt;

&lt;p&gt;Searching is one of the most useful features.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then type a word.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/recursive
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Enter
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Go to the next match:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;n
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Previous match:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;N
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This saves a huge amount of time.&lt;/p&gt;




&lt;h1&gt;
  
  
  Searching for Man Pages
&lt;/h1&gt;

&lt;p&gt;Don't know the command name?&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;man &lt;span class="nt"&gt;-k&lt;/span&gt; copy
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cp
install
dd
rsync
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Linux searches manual descriptions.&lt;/p&gt;




&lt;h1&gt;
  
  
  What If Multiple Man Pages Exist?
&lt;/h1&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;man &lt;span class="nt"&gt;-a&lt;/span&gt; &lt;span class="nb"&gt;printf&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Linux will show every available manual page.&lt;/p&gt;




&lt;h1&gt;
  
  
  Viewing the File Location
&lt;/h1&gt;

&lt;p&gt;Want to know where the documentation lives?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;man &lt;span class="nt"&gt;-w&lt;/span&gt; &lt;span class="nb"&gt;ls&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/usr/share/man/man1/ls.1.gz
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h1&gt;
  
  
  Reading C Programming Documentation
&lt;/h1&gt;

&lt;p&gt;If you're a C programmer, this is one of the most important skills.&lt;/p&gt;

&lt;p&gt;Instead of searching online for a function:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="n"&gt;malloc&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Read its manual:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;man 3 malloc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You'll learn:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Parameters&lt;/li&gt;
&lt;li&gt;Return value&lt;/li&gt;
&lt;li&gt;Errors&lt;/li&gt;
&lt;li&gt;Examples&lt;/li&gt;
&lt;li&gt;Standards&lt;/li&gt;
&lt;li&gt;Thread safety&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Other useful examples:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;man 2 &lt;span class="nb"&gt;read
&lt;/span&gt;man 2 write
man 2 open
man 2 close
man 3 fopen
man 3 &lt;span class="nb"&gt;printf
&lt;/span&gt;man 3 pthread_create
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h1&gt;
  
  
  A Professional Reading Workflow
&lt;/h1&gt;

&lt;p&gt;Experienced developers rarely read an entire man page from top to bottom.&lt;/p&gt;

&lt;p&gt;Instead, they follow a focused workflow:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Read &lt;strong&gt;NAME&lt;/strong&gt; to understand the command's purpose.&lt;/li&gt;
&lt;li&gt;Check &lt;strong&gt;SYNOPSIS&lt;/strong&gt; to learn the required syntax.&lt;/li&gt;
&lt;li&gt;Read &lt;strong&gt;DESCRIPTION&lt;/strong&gt; for behavior and limitations.&lt;/li&gt;
&lt;li&gt;Jump to &lt;strong&gt;OPTIONS&lt;/strong&gt; and review only the flags you need.&lt;/li&gt;
&lt;li&gt;Use &lt;code&gt;/&lt;/code&gt; to search for keywords related to your task.&lt;/li&gt;
&lt;li&gt;Look at &lt;strong&gt;SEE ALSO&lt;/strong&gt; to discover related commands or APIs.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This approach is much faster than reading every section sequentially.&lt;/p&gt;




&lt;h1&gt;
  
  
  Common Beginner Mistakes
&lt;/h1&gt;

&lt;h3&gt;
  
  
  Reading Every Line
&lt;/h3&gt;

&lt;p&gt;Most man pages are reference documents, not tutorials.&lt;/p&gt;

&lt;p&gt;Read only the sections relevant to your current task.&lt;/p&gt;




&lt;h3&gt;
  
  
  Ignoring SYNOPSIS
&lt;/h3&gt;

&lt;p&gt;The syntax line explains how to use the command correctly.&lt;/p&gt;

&lt;p&gt;Always study it before trying examples.&lt;/p&gt;




&lt;h3&gt;
  
  
  Not Using Search
&lt;/h3&gt;

&lt;p&gt;Searching with &lt;code&gt;/&lt;/code&gt; is significantly faster than scrolling through long pages.&lt;/p&gt;




&lt;h3&gt;
  
  
  Ignoring SEE ALSO
&lt;/h3&gt;

&lt;p&gt;Many useful Linux tools are discovered through this section.&lt;/p&gt;




&lt;h3&gt;
  
  
  Depending Only on Google
&lt;/h3&gt;

&lt;p&gt;Search engines often lead to outdated or incomplete information.&lt;/p&gt;

&lt;p&gt;The man page installed on your system matches the software version you're using.&lt;/p&gt;




&lt;h1&gt;
  
  
  Best Commands to Practice Reading
&lt;/h1&gt;

&lt;p&gt;Start with these commands:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;man &lt;span class="nb"&gt;ls
&lt;/span&gt;man &lt;span class="nb"&gt;cp
&lt;/span&gt;man &lt;span class="nb"&gt;mv
&lt;/span&gt;man &lt;span class="nb"&gt;rm
&lt;/span&gt;man &lt;span class="nb"&gt;cat
&lt;/span&gt;man &lt;span class="nb"&gt;pwd
&lt;/span&gt;man &lt;span class="nb"&gt;cd
&lt;/span&gt;man &lt;span class="nb"&gt;grep
&lt;/span&gt;man &lt;span class="nb"&gt;sed
&lt;/span&gt;man &lt;span class="nb"&gt;awk
&lt;/span&gt;man find
man &lt;span class="nb"&gt;chmod
&lt;/span&gt;man &lt;span class="nb"&gt;chown
&lt;/span&gt;man &lt;span class="nb"&gt;tar
&lt;/span&gt;man &lt;span class="nb"&gt;gzip&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you're learning C on Linux:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;man 2 open
man 2 &lt;span class="nb"&gt;read
&lt;/span&gt;man 2 write
man 2 mmap
man 2 fork
man 2 execve
man 3 malloc
man 3 free
man 3 &lt;span class="nb"&gt;printf
&lt;/span&gt;man 3 fopen
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h1&gt;
  
  
  Final Thoughts
&lt;/h1&gt;

&lt;p&gt;Learning Linux isn't about memorizing every command or every option. It's about knowing where to find reliable information when you need it.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;man&lt;/code&gt; command gives you direct access to the official documentation for your system. Once you're comfortable reading the &lt;strong&gt;NAME&lt;/strong&gt;, &lt;strong&gt;SYNOPSIS&lt;/strong&gt;, &lt;strong&gt;DESCRIPTION&lt;/strong&gt;, and &lt;strong&gt;OPTIONS&lt;/strong&gt; sections—and using search effectively—you'll spend less time hunting for answers online and more time understanding how Linux actually works.&lt;/p&gt;

&lt;p&gt;Whether you're a Linux beginner, a system administrator, a DevOps engineer, or a C programmer building low-level software, mastering man pages is a skill that will continue to pay off throughout your career.&lt;/p&gt;

</description>
      <category>linux</category>
      <category>manpages</category>
      <category>productivity</category>
      <category>programming</category>
    </item>
    <item>
      <title>50 Most Used Linux Commands for Programmers</title>
      <dc:creator>Farhad Rahimi Klie</dc:creator>
      <pubDate>Sun, 05 Jul 2026 03:33:42 +0000</pubDate>
      <link>https://dev.to/farhadrahimiklie/50-most-used-linux-commands-for-programmers-29ba</link>
      <guid>https://dev.to/farhadrahimiklie/50-most-used-linux-commands-for-programmers-29ba</guid>
      <description>&lt;p&gt;Linux is the backbone of modern development environments—from backend servers to DevOps pipelines and cloud systems. Whether you’re writing code, debugging applications, or managing servers, mastering Linux commands significantly boosts productivity.&lt;/p&gt;

&lt;p&gt;Below are &lt;strong&gt;50 essential Linux commands every programmer should know&lt;/strong&gt;, grouped by purpose for easier learning.&lt;/p&gt;




&lt;h2&gt;
  
  
  1. File and Directory Navigation
&lt;/h2&gt;

&lt;p&gt;These commands help you move around the filesystem quickly and efficiently.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. &lt;code&gt;pwd&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
Prints the current working directory. Useful when you’re lost in nested folders.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. &lt;code&gt;ls&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
Lists files and directories. Add &lt;code&gt;-l&lt;/code&gt; for detailed view or &lt;code&gt;-a&lt;/code&gt; to show hidden files.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. &lt;code&gt;cd&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
Changes directory. Example: &lt;code&gt;cd /var/www&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. &lt;code&gt;tree&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
Displays directory structure in a tree format (may need installation).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. &lt;code&gt;find&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
Searches for files and directories based on conditions like name or type.&lt;/p&gt;




&lt;h2&gt;
  
  
  2. File Operations
&lt;/h2&gt;

&lt;p&gt;These are used constantly in development workflows.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;6. &lt;code&gt;touch&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
Creates an empty file or updates timestamp.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;7. &lt;code&gt;cp&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
Copies files or directories.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;8. &lt;code&gt;mv&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
Moves or renames files.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;9. &lt;code&gt;rm&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
Deletes files or directories. Use carefully.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;10. &lt;code&gt;mkdir&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
Creates a new directory.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;11. &lt;code&gt;rmdir&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
Removes empty directories.&lt;/p&gt;




&lt;h2&gt;
  
  
  3. File Viewing and Text Processing
&lt;/h2&gt;

&lt;p&gt;Crucial for reading logs, configs, and code files.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;12. &lt;code&gt;cat&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
Displays file content.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;13. &lt;code&gt;less&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
View large files page by page.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;14. &lt;code&gt;head&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
Shows first 10 lines of a file.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;15. &lt;code&gt;tail&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
Shows last 10 lines (useful for logs).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;16. &lt;code&gt;nano&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
Simple terminal text editor.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;17. &lt;code&gt;vim&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
Powerful advanced text editor widely used by developers.&lt;/p&gt;




&lt;h2&gt;
  
  
  4. Permissions and Ownership
&lt;/h2&gt;

&lt;p&gt;Important for security and server management.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;18. &lt;code&gt;chmod&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
Changes file permissions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;19. &lt;code&gt;chown&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
Changes file owner and group.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;20. &lt;code&gt;umask&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
Sets default permissions for new files.&lt;/p&gt;




&lt;h2&gt;
  
  
  5. Process Management
&lt;/h2&gt;

&lt;p&gt;Used for monitoring and controlling running applications.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;21. &lt;code&gt;ps&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
Displays running processes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;22. &lt;code&gt;top&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
Real-time system process monitoring.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;23. &lt;code&gt;htop&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
Improved version of &lt;code&gt;top&lt;/code&gt; (interactive UI).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;24. &lt;code&gt;kill&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
Terminates a process by PID.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;25. &lt;code&gt;pkill&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
Kills process by name.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;26. &lt;code&gt;jobs&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
Shows background jobs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;27. &lt;code&gt;fg&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
Brings background job to foreground.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;28. &lt;code&gt;bg&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
Resumes a stopped job in background.&lt;/p&gt;




&lt;h2&gt;
  
  
  6. Networking Commands
&lt;/h2&gt;

&lt;p&gt;Essential for APIs, servers, and debugging network issues.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;29. &lt;code&gt;ping&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
Checks connectivity to a host.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;30. &lt;code&gt;curl&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
Transfers data from/to servers via HTTP.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;31. &lt;code&gt;wget&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
Downloads files from the web.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;32. &lt;code&gt;netstat&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
Shows network connections and ports.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;33. &lt;code&gt;ss&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
Modern replacement for &lt;code&gt;netstat&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;34. &lt;code&gt;ifconfig&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
Displays network interfaces (deprecated but still used).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;35. &lt;code&gt;ip&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
Modern tool for network configuration.&lt;/p&gt;




&lt;h2&gt;
  
  
  7. Disk and Storage
&lt;/h2&gt;

&lt;p&gt;For managing space and file systems.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;36. &lt;code&gt;df&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
Shows disk space usage.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;37. &lt;code&gt;du&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
Shows directory size.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;38. &lt;code&gt;lsblk&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
Lists block devices (disks, partitions).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;39. &lt;code&gt;mount&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
Mounts file systems.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;40. &lt;code&gt;umount&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
Unmounts file systems.&lt;/p&gt;




&lt;h2&gt;
  
  
  8. Compression and Archiving
&lt;/h2&gt;

&lt;p&gt;Useful for backups and deployments.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;41. &lt;code&gt;tar&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
Creates and extracts archives.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;42. &lt;code&gt;zip&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
Compresses files into .zip format.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;43. &lt;code&gt;unzip&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
Extracts zip files.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;44. &lt;code&gt;gzip&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
Compresses files using gzip.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;45. &lt;code&gt;gunzip&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
Decompresses gzip files.&lt;/p&gt;




&lt;h2&gt;
  
  
  9. System Information
&lt;/h2&gt;

&lt;p&gt;Helpful for understanding system state.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;46. &lt;code&gt;uname&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
Displays system information.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;47. &lt;code&gt;uptime&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
Shows how long system has been running.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;48. &lt;code&gt;whoami&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
Displays current user.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;49. &lt;code&gt;history&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
Shows previously executed commands.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;50. &lt;code&gt;alias&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
Creates shortcuts for long commands.&lt;/p&gt;




&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;These 50 Linux commands form a strong foundation for any programmer working in Linux environments. You don’t need to memorize everything at once—start with navigation, file operations, and process management, then gradually expand into networking and system tools.&lt;/p&gt;

&lt;p&gt;With regular use, these commands become muscle memory and significantly improve your speed, debugging ability, and overall workflow efficiency.&lt;/p&gt;

</description>
      <category>linux</category>
      <category>learning</category>
      <category>productivity</category>
      <category>cli</category>
    </item>
  </channel>
</rss>
