|
| 1 | +--- |
| 2 | +sidebar_position: 2 |
| 3 | +title: "The Linux File System" |
| 4 | +sidebar_label: "2. Linux File System" |
| 5 | +description: "Understand the unique Everything is a File philosophy and the standard directory structure of a Linux server." |
| 6 | +--- |
| 7 | + |
| 8 | +Before we look at folders, let’s answer the most common question: **What exactly is Linux?** |
| 9 | + |
| 10 | +:::info What is Linux? |
| 11 | +**Linux** is not a single "app" or a company product like Windows. It is an **Open-Source Kernel** (the core engine of an OS). |
| 12 | + |
| 13 | +Think of Linux as the **Engine** of a car. Different companies take that engine, add a different "body" (UI), "seats" (Apps), and "paint" (Themes), and call it a **Distribution** (or **Distro**). |
| 14 | +* **Ubuntu:** The friendly "Sedan" for beginners. |
| 15 | +* **CentOS/RHEL:** The heavy-duty "Truck" for big companies. |
| 16 | +* **Kali Linux:** The "Spy Car" for security experts. |
| 17 | +::: |
| 18 | + |
| 19 | +## The "Everything is a File" Philosophy |
| 20 | + |
| 21 | +This is the most important concept in Linux. |
| 22 | +* Your **Hard Drive**? It's a file located at `/dev/sda`. |
| 23 | +* Your **Keyboard**? It's a file located at `/dev/input/event0`. |
| 24 | +* Your **Process**? It’s a folder full of files in `/proc`. |
| 25 | + |
| 26 | +**Why does this matter?** Because it means you can use the same simple tools (like `cat`, `grep`, or `nano`) to fix a website, check your RAM, or configure a database. You don't need a special "Dashboard" for everything. |
| 27 | + |
| 28 | +## The Linux Tree Structure (FHS) |
| 29 | + |
| 30 | +In Windows, you have `C:\` and `D:\`. In Linux, everything starts from a single point called the **Root**, represented by a forward slash: `/`. |
| 31 | + |
| 32 | +### The Essential Directories for DevOps: |
| 33 | + |
| 34 | +| Directory | Human Name | What's inside? | |
| 35 | +| :--- | :--- | :--- | |
| 36 | +| `/` | **Root** | The parent of every other folder on the system. | |
| 37 | +| `/bin` | **Binaries** | The "Power Tools" (commands like `ls`, `cp`, `mkdir`). | |
| 38 | +| `/etc` | **Et Cetera** | The **Control Room**. Almost all configuration files live here. | |
| 39 | +| `/home` | **Home** | The personal "Apartment" for each user (e.g., `/home/ajay`). | |
| 40 | +| `/var/log` | **Logs** | The "Black Box." If an app crashes, the reason is written here. | |
| 41 | +| `/tmp` | **Temporary** | The "Trash Can." Files here are usually deleted on reboot. | |
| 42 | +| `/root` | **Root Home** | The private home for the "God Mode" (Superuser) user. | |
| 43 | +| `/dev` | **Devices** | Where your hardware "files" live (Hard drives, USBs). | |
| 44 | + |
| 45 | +## Absolute vs. Relative Paths |
| 46 | + |
| 47 | +As a new coder at **CodeHarborHub**, you must know how to navigate the tree. |
| 48 | + |
| 49 | +1. **Absolute Path:** The full address starting from the Root. |
| 50 | + * *Example:* `/home/ajay/projects/codeharborhub` |
| 51 | + * (Like giving someone your full mailing address: Country, City, Street, House No.) |
| 52 | + |
| 53 | +2. **Relative Path:** The address starting from where you are **now**. |
| 54 | + * *Example:* If you are already in `/home/ajay`, the relative path is just `projects/codeharborhub`. |
| 55 | + * (Like telling someone in your house, "The kitchen is the next door on the left.") |
| 56 | + |
| 57 | +:::info The Symbols |
| 58 | +* `.` (Single Dot): Refers to the **Current** directory. |
| 59 | +* `..` (Double Dot): Refers to the **Parent** directory (one level up). |
| 60 | +* `~` (Tilde): Refers to your **Home** directory. |
| 61 | +::: |
| 62 | + |
| 63 | +## Why DevOps Engineers Love This Structure |
| 64 | + |
| 65 | +Imagine you are deploying a website. |
| 66 | +1. You put your code in `/var/www/html`. |
| 67 | +2. You configure the webserver (Nginx) in `/etc/nginx`. |
| 68 | +3. You check why it’s not working in `/var/log/nginx/error.log`. |
| 69 | + |
| 70 | +Because every Linux server follows this **Filesystem Hierarchy Standard (FHS)**, once you learn it, you can manage any server in the world—whether it's at Google, Amazon, or on your local machine. |
| 71 | + |
| 72 | +## How to "Look" at the File System |
| 73 | + |
| 74 | +When you open your terminal, use these three magic commands to explore: |
| 75 | + |
| 76 | +* `pwd`: **P**rint **W**orking **D**irectory (Where am I?). |
| 77 | +* `ls`: **L**ist (What's in here?). |
| 78 | +* `cd`: **C**hange **D**irectory (Move me somewhere else). |
| 79 | + |
| 80 | +:::info Why this matters for you |
| 81 | +As a developer at **CodeHarborHub**, you will spend a lot of time in the `/etc` folder configuring web servers like Nginx and in the `/var/log` folder debugging why your Node.js app won't start. Mastering this "Map" is 50% of the battle! |
| 82 | +::: |
| 83 | + |
| 84 | +## Summary Checklist |
| 85 | +* [x] I understand that Linux is a "Kernel" and Ubuntu is a "Distro." |
| 86 | +* [x] I know that `/` is the root of the entire system. |
| 87 | +* [x] I can explain why `/etc` and `/var/log` are important for DevOps. |
| 88 | +* [x] I know the difference between an Absolute and a Relative path. |
| 89 | + |
| 90 | +:::success Mastery Moment |
| 91 | +You now know the "Map" of the Linux world. You won't get lost anymore! Next, we need to learn who is allowed to open these files. |
| 92 | +::: |
0 commit comments