diff --git a/absolute-beginners/devops-beginner/operating-system/_category_.json b/absolute-beginners/devops-beginner/operating-system/_category_.json new file mode 100644 index 0000000..62ae193 --- /dev/null +++ b/absolute-beginners/devops-beginner/operating-system/_category_.json @@ -0,0 +1,8 @@ +{ + "label": "Operating System", + "position": 3, + "link": { + "type": "generated-index", + "description": "Master the heart of the cloud. Learn how Linux manages memory, processes, and files to host your applications reliably." + } +} \ No newline at end of file diff --git a/absolute-beginners/devops-beginner/operating-system/linux-file-system.mdx b/absolute-beginners/devops-beginner/operating-system/linux-file-system.mdx new file mode 100644 index 0000000..4c434d0 --- /dev/null +++ b/absolute-beginners/devops-beginner/operating-system/linux-file-system.mdx @@ -0,0 +1,92 @@ +--- +sidebar_position: 2 +title: "The Linux File System" +sidebar_label: "2. Linux File System" +description: "Understand the unique Everything is a File philosophy and the standard directory structure of a Linux server." +--- + +Before we look at folders, let’s answer the most common question: **What exactly is Linux?** + +:::info What is Linux? +**Linux** is not a single "app" or a company product like Windows. It is an **Open-Source Kernel** (the core engine of an OS). + +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**). +* **Ubuntu:** The friendly "Sedan" for beginners. +* **CentOS/RHEL:** The heavy-duty "Truck" for big companies. +* **Kali Linux:** The "Spy Car" for security experts. +::: + +## The "Everything is a File" Philosophy + +This is the most important concept in Linux. +* Your **Hard Drive**? It's a file located at `/dev/sda`. +* Your **Keyboard**? It's a file located at `/dev/input/event0`. +* Your **Process**? It’s a folder full of files in `/proc`. + +**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. + +## The Linux Tree Structure (FHS) + +In Windows, you have `C:\` and `D:\`. In Linux, everything starts from a single point called the **Root**, represented by a forward slash: `/`. + +### The Essential Directories for DevOps: + +| Directory | Human Name | What's inside? | +| :--- | :--- | :--- | +| `/` | **Root** | The parent of every other folder on the system. | +| `/bin` | **Binaries** | The "Power Tools" (commands like `ls`, `cp`, `mkdir`). | +| `/etc` | **Et Cetera** | The **Control Room**. Almost all configuration files live here. | +| `/home` | **Home** | The personal "Apartment" for each user (e.g., `/home/ajay`). | +| `/var/log` | **Logs** | The "Black Box." If an app crashes, the reason is written here. | +| `/tmp` | **Temporary** | The "Trash Can." Files here are usually deleted on reboot. | +| `/root` | **Root Home** | The private home for the "God Mode" (Superuser) user. | +| `/dev` | **Devices** | Where your hardware "files" live (Hard drives, USBs). | + +## Absolute vs. Relative Paths + +As a new coder at **CodeHarborHub**, you must know how to navigate the tree. + +1. **Absolute Path:** The full address starting from the Root. + * *Example:* `/home/ajay/projects/codeharborhub` + * (Like giving someone your full mailing address: Country, City, Street, House No.) + +2. **Relative Path:** The address starting from where you are **now**. + * *Example:* If you are already in `/home/ajay`, the relative path is just `projects/codeharborhub`. + * (Like telling someone in your house, "The kitchen is the next door on the left.") + +:::info The Symbols +* `.` (Single Dot): Refers to the **Current** directory. +* `..` (Double Dot): Refers to the **Parent** directory (one level up). +* `~` (Tilde): Refers to your **Home** directory. +::: + +## Why DevOps Engineers Love This Structure + +Imagine you are deploying a website. +1. You put your code in `/var/www/html`. +2. You configure the webserver (Nginx) in `/etc/nginx`. +3. You check why it’s not working in `/var/log/nginx/error.log`. + +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. + +## How to "Look" at the File System + +When you open your terminal, use these three magic commands to explore: + +* `pwd`: **P**rint **W**orking **D**irectory (Where am I?). +* `ls`: **L**ist (What's in here?). +* `cd`: **C**hange **D**irectory (Move me somewhere else). + +:::info Why this matters for you +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! +::: + +## Summary Checklist +* [x] I understand that Linux is a "Kernel" and Ubuntu is a "Distro." +* [x] I know that `/` is the root of the entire system. +* [x] I can explain why `/etc` and `/var/log` are important for DevOps. +* [x] I know the difference between an Absolute and a Relative path. + +:::success Mastery Moment +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. +::: \ No newline at end of file diff --git a/absolute-beginners/devops-beginner/operating-system/networking-basics.mdx b/absolute-beginners/devops-beginner/operating-system/networking-basics.mdx new file mode 100644 index 0000000..aee1c23 --- /dev/null +++ b/absolute-beginners/devops-beginner/operating-system/networking-basics.mdx @@ -0,0 +1,82 @@ +--- +sidebar_position: 6 +title: "Networking Basics for DevOps" +sidebar_label: "6. Networking Basics" +description: "Learn how servers communicate using IP addresses, Ports, DNS, and the magic of SSH." +--- + +Imagine you want to send a physical letter to a friend. You need: +1. **A House Address** (IP Address). +2. **A Specific Room Number** (Port). +3. **A Delivery Service** (Protocols like TCP/UDP). + +In the world of **CodeHarborHub**, understanding these three things is the difference between a working website and a "Site Can't Be Reached" error. + +## 1. The IP Address (The Home Address) + +Every machine connected to the internet has a unique **IP (Internet Protocol) Address**. + +* **Public IP:** Your server's "Global" address that the whole world can see. +* **Private IP:** The "Internal" address used only inside your private cloud (like AWS VPC). +* **Localhost (`127.0.0.1`):** A special address that means "This machine right here." + +:::info The Apartment Analogy +The **IP Address** gets the mail to the building (The Server). The **Port** tells the mail which apartment (The App) to go to. +::: + +## 2. Ports: The Digital Doors + +Your server can run many apps at once (a Web Server, a Database, and an Email server). How does the computer know which traffic belongs to which app? **Ports.** + +| Common Port | Service | What it does | +| :--- | :--- | :--- | +| **22** | **SSH** | Securely login to your server remotely. | +| **80** | **HTTP** | Standard, unencrypted web traffic. | +| **443** | **HTTPS** | Secure, encrypted web traffic (The Gold Standard). | +| **3000 / 8080** | **Dev** | Common ports for Node.js or React apps in development. | +| **5432** | **Postgres** | The "door" for your Database. | + +## 3. DNS: The Internet's Phonebook + +Humans are bad at remembering numbers like `142.250.190.46`. We are good at remembering names like `google.com` or `codeharborhub.com`. + +**DNS (Domain Name System)** is a giant database that translates a "URL" into an "IP Address." When you type a website name, your computer asks a DNS server: *"Hey, what's the IP for this name?"* and then connects you. + +## 4. SSH: The DevOps Magic Wand + +**SSH (Secure Shell)** is the most important tool for a DevOps engineer. It allows you to open a terminal on a server that is thousands of miles away as if you were sitting right in front of it. + +```bash +# How to login to your server +ssh username@your-server-ip +``` + +:::info Keys vs. Passwords +Professional servers don't use passwords for SSH; they use **SSH Keys**. + +* **Public Key:** Stays on the server (The Lock). +* **Private Key:** Stays on your laptop (The Key). + +Only the person with the private key can get in! +::: + +## Resources for Deeper Learning + +Ready to become a networking pro? Here are the best places to go next: + +### Official Documentation & Guides + +* **[Cloudflare Learning Center](https://www.cloudflare.com/learning/):** The best beginner-friendly explanations of DNS, IP, and Web Security. +* **[Linux Journey - Networking](https://linuxjourney.com/lesson/network-basics):** A fantastic, free interactive site for learning Linux networking commands. +* **[MDN Web Docs - How the Web Works](https://developer.mozilla.org/en-US/docs/Learn/Getting_started_with_the_web/How_the_web_works):** Great for understanding the request/response cycle. + +### Video Tutorials + +* **[NetworkChuck (YouTube)](https://www.youtube.com/@NetworkChuck):** Extremely high-energy and visual explanations of IP addresses and Subnetting. + +## Summary Checklist + +* [x] I can explain the difference between an IP and a Port. +* [x] I know that Port 80/443 are for Web traffic and Port 22 is for SSH. +* [x] I understand that DNS translates names into numbers. +* [x] I know that SSH Keys are safer than passwords. diff --git a/absolute-beginners/devops-beginner/operating-system/os-fundamentals.mdx b/absolute-beginners/devops-beginner/operating-system/os-fundamentals.mdx new file mode 100644 index 0000000..e38bab5 --- /dev/null +++ b/absolute-beginners/devops-beginner/operating-system/os-fundamentals.mdx @@ -0,0 +1,67 @@ +--- +sidebar_position: 1 +title: "OS Fundamentals: The Heart of the Machine" +sidebar_label: "1. OS Fundamentals" +description: "A beginner-friendly guide to understanding how Operating Systems work, focusing on the Linux architecture used in DevOps." +--- + +Welcome to the foundation of DevOps! Before you can automate a server, you need to understand what a server actually *is*. + +Think of a computer without an Operating System (OS) as a library full of books but with **no librarian**. The books (data) are there, and the shelves (hardware) are there, but there is no one to help you find a book, check it out, or make sure the shelves don't collapse. + +**The OS is your Librarian.** + +## The 4-Layer Architecture + +In DevOps, we primarily use **Linux**. To understand Linux, imagine an onion with four layers. To get to the center (the hardware), you have to go through the software layers. + +### 1. The Hardware (The Physical Body) +This is the "Metal." It includes your **CPU** (The Brain), **RAM** (Short-term Memory), and **Hard Drive** (Long-term Storage). Hardware is powerful but "dumb"—it doesn't know how to run a Python script by itself. + +### 2. The Kernel (The Boss) +The Kernel is the most important part of the OS. It is the only layer that can talk directly to the hardware. +* **What it does:** It decides which program gets to use the CPU and how much RAM each app can have. +* **In DevOps:** When your "Container" or "App" crashes, it’s usually because the Kernel stepped in and said, "No, you're using too much memory!" + +### 3. The Shell (The Translator) +Since humans can't speak "Binary" (0s and 1s), we use the **Shell**. The Shell is a program that takes your typed commands (like `mkdir` or `git push`) and translates them into instructions the Kernel understands. +* **Common Shells:** Bash (Standard), Zsh (Fancy), Fish (User-friendly). + +### 4. User Space (The Playground) +This is where **you** live. Your web browser, your VS Code, your Docker containers, and your Node.js APIs all run here. These apps are "restricted"—they aren't allowed to touch the hardware directly; they must ask the Kernel for permission. + +## The Multi-Tasking Magic + +How can your server run a Database, a Web Server, and a Logging tool all at the same time? + +The OS uses a concept called **Process Scheduling**. +Imagine a chef (The CPU) cooking 10 different meals. The chef doesn't finish one meal before starting the next. Instead, they chop onions for 5 seconds, then flip a pancake for 5 seconds, then stir the soup for 5 seconds. + +The OS switches between tasks so fast (millions of times per second) that it *looks* like everything is happening at once. This is called **Concurrency**. + +## Why Linux for DevOps? + +You might use Windows or Mac at home, but in the world of Cloud and DevOps, **Linux is King**. Here is why: + +1. **Open Source:** It's free! You don't have to pay Microsoft for every server you spin up. +2. **Lightweight:** A Windows server needs a lot of RAM just to show a desktop. A Linux server can run with no "screen" (Headless), saving all its power for your app. +3. **The Package System:** Installing software on Linux is as easy as typing `apt install nginx`. It was built for automation. + +## Key Concepts to Remember + +| Concept | Human-Friendly Explanation | +| :--- | :--- | +| **Booting** | The process of the Kernel waking up the hardware and starting the OS. | +| **Root User** | The "God Mode" user who has permission to do *anything* on the system. | +| **File Descriptor** | A unique ID the OS gives to every open file or network connection. | +| **Drivers** | Small pieces of code that teach the Kernel how to talk to new hardware (like a printer). | + +## Summary Checklist +* [x] I know that the **Kernel** is the bridge between software and hardware. +* [x] I understand that the **Shell** is my interface to talk to the OS. +* [x] I can explain why Linux is better for servers than Windows. +* [x] I understand that "User Space" is where my applications run safely. + +:::tip Mindset Shift +As a DevOps engineer at **CodeHarborHub**, don't think of Linux as an "Operating System." Think of it as a **Set of APIs**. Every command you learn is just a way to ask the Kernel to do work for you. +::: \ No newline at end of file diff --git a/absolute-beginners/devops-beginner/operating-system/package-management.mdx b/absolute-beginners/devops-beginner/operating-system/package-management.mdx new file mode 100644 index 0000000..f05bcd2 --- /dev/null +++ b/absolute-beginners/devops-beginner/operating-system/package-management.mdx @@ -0,0 +1,97 @@ +--- +sidebar_position: 5 +title: "Package Management" +sidebar_label: "5. Package Management" +description: "Learn how to install, update, and manage software on Linux using APT, YUM, and Snap." +--- + +When you want to install a web server like **Nginx**, a database like **PostgreSQL**, or a tool like **Git**, you don't go to a website and click "Download." Instead, you ask your OS to go to a **Repository** (a trusted library of software) and grab it for you. + +## What is a "Package"? + +In Linux, a "Package" is a compressed file that contains: +1. **The Application:** The actual code/binary. +2. **Metadata:** Information about the version and who built it. +3. **Dependencies:** A list of *other* software the app needs to run. + +:::info The Dependency Chain +Imagine you want to install a "Book" (The App). But the book requires a "Shelf" (Dependency A) to stand on, and the shelf requires "Screws" (Dependency B) to be built. +A **Package Manager** is smart enough to see this and say: *"I will download the Book, the Shelf, and the Screws all at once for you."* +::: + +## The Different "App Stores" (Managers) + +Because there are different "Distros" of Linux, there are different managers. As a **CodeHarborHub** engineer, you should know the two most common ones: + + + + Used by the most popular server OS, **Ubuntu**. + * **Command:** `apt` (Advanced Package Tool) + * **File Type:** `.deb` + + + Used by "Enterprise" grade Linux systems like Red Hat. + * **Command:** `yum` or `dnf` + * **File Type:** `.rpm` + + + +## Essential Commands for Every Day + +Let's look at how to use `apt` (the most common tool you'll use). + +### 1. Update the "Catalog" +Before installing anything, you must tell Linux to check if there are new versions of software available in the online library. +```bash +sudo apt update +``` + +### 2. Install Software + +Want to install the Nginx web server? It's one line: + +```bash +sudo apt install nginx +``` + +### 3. Remove Software + +If you no longer need a tool, clean it up: + +```bash +sudo apt remove git +``` + +### 4. Upgrade Everything + +To keep your server secure, you should upgrade all your installed apps to the latest versions: + +```bash +sudo apt upgrade +``` + +## What are Snaps and Flatpaks? + +Sometimes, an app is very complex and needs very specific versions of dependencies that might break your system. To solve this, developers created **Snaps**. + +:::info The Bento Box Analogy +Think of a regular package like a meal on a plate where all the food touches. A **Snap** is like a **Bento Box**. It puts the app and all its specific dependencies in a "box" so they don't interfere with the rest of your system. +**Common Snaps:** Docker, Certbot (for SSL), and VS Code. +::: + +## Safety Rules for Package Management + +1. **Always `sudo`:** You are changing the system, so you need "Manager" powers. +2. **Update before Install:** Always run `apt update` first so you don't install an old, buggy version of a tool. +3. **Read the Output:** Linux will tell you if it's about to delete something important. **Read before you press "Y"!** + +## Summary Checklist + + * [x] I understand that a Package Manager handles dependencies automatically. + * [x] I know that **APT** is for Ubuntu and **YUM** is for CentOS. + * [x] I can explain the difference between `apt update` and `apt upgrade`. + * [x] I understand that Snaps are "isolated" versions of apps. + +:::info Why this matters for DevOps +In the next module, we will build a **CI/CD Pipeline**. Your pipeline will need to "Spin up" a server and automatically run `apt install` to set up your environment. If you don't understand how packages work, your automated deployments will fail\! +::: \ No newline at end of file diff --git a/absolute-beginners/devops-beginner/operating-system/permissions-security.mdx b/absolute-beginners/devops-beginner/operating-system/permissions-security.mdx new file mode 100644 index 0000000..440c572 --- /dev/null +++ b/absolute-beginners/devops-beginner/operating-system/permissions-security.mdx @@ -0,0 +1,76 @@ +--- +sidebar_position: 3 +title: "Permissions & Security" +sidebar_label: "3. Permissions & Security" +description: "Master the art of Linux file permissions, ownership, and the power of Sudo." +--- + +Imagine you are running a hotel (**Your Server**). +* The **Manager** (Root User) has a master key to every room. +* The **Guests** (Users) only have keys to their own rooms. +* The **Cleaners** (Service Accounts) only have keys to the supply closets. + +In Linux, we manage these "keys" using **Permissions** and **Ownership**. + +## The Three Types of "People" + +Every file and folder in Linux belongs to three categories of people: + +1. **User (u):** The individual person who owns the file. +2. **Group (g):** A collection of users (e.g., the "developers" group). +3. **Others (o):** Everyone else in the world (The "Public"). + +## The "rwx" Code + +When you run the command `ls -l` in your terminal, you will see a strange string of letters like `-rwxr-xr--`. Let’s decode it: + +* **r (Read):** Can you open and see the contents? +* **w (Write):** Can you edit or delete the file? +* **x (Execute):** Can you "run" the file (like a script or an app)? + +:::info The Numeric Method (Octal) +Professional DevOps engineers often use numbers instead of letters: +* **4** = Read | **2** = Write | **1** = Execute +* **7** (4+2+1) = Full Access (rwx) +* **5** (4+0+1) = Read & Execute (r-x) +* **6** (4+2+0) = Read & Write (rw-) +::: + +## Essential Security Commands + +To manage your "Hotel," you need these three tools: + +### 1. `chmod` (Change Mode) +Used to change **permissions**. +* *Example:* `chmod 755 script.sh` (Owner can do everything, others can only read/run). +* *Example:* `chmod +x backup.py` (Make a script runnable). + +### 2. `chown` (Change Owner) +Used to change **who owns** the file. +* *Example:* `chown ajay:developers website.html` (Makes Ajay the owner and "developers" the group). + +### 3. `sudo` (SuperUser DO) +This is the most powerful command. It tells Linux: "I know this is dangerous, but let me do it anyway using my Manager powers." +* *Example:* `sudo apt update` (You need Manager powers to install software). + +## Best Practices for CodeHarborHub + +:::warning The Rule of "Least Privilege" +Never give a file more permission than it needs. +* **Bad:** Giving every file `777` (Everyone can do everything). This is a massive security hole! +* **Good:** Only give `x` (execute) permission to scripts that actually need to run. +::: + +1. **Avoid Root:** Don't stay logged in as the "Root" user. Use your normal account and only use `sudo` when necessary. +2. **Check your `ls -l`:** Get into the habit of checking who owns a file before you try to edit it. +3. **Group Power:** Instead of giving permissions to 10 different people, add them all to a "group" and give permissions to that group. + +## Summary Checklist +* [x] I can identify the difference between User, Group, and Others. +* [x] I understand what **r**, **w**, and **x** stand for. +* [x] I know that **755** is a common safe permission for scripts. +* [x] I understand that `sudo` should be used with caution. + +:::info Why this matters for DevOps +In a CI/CD pipeline, if your script doesn't have "Execute" (x) permission, your build will fail. If your web server (Nginx) doesn't have "Read" (r) permission for your HTML files, your website will show a "403 Forbidden" error. Mastering permissions is the key to solving 90% of server errors! +::: \ No newline at end of file diff --git a/absolute-beginners/devops-beginner/operating-system/process-management.mdx b/absolute-beginners/devops-beginner/operating-system/process-management.mdx new file mode 100644 index 0000000..18bb3f4 --- /dev/null +++ b/absolute-beginners/devops-beginner/operating-system/process-management.mdx @@ -0,0 +1,70 @@ +--- +sidebar_position: 4 +title: Process Management +sidebar_label: "4. Process Management" +description: "Learn how to monitor, manage, and control running applications on a Linux server." +--- + +When you write code in VS Code, it's just a "File." But the moment you type `node app.js` or `python script.py`, that code springs to life and becomes a **Process**. + +A Process is a living, breathing program that has its own ID (PID), consumes memory (RAM), and uses the CPU to perform tasks. + +## How to See What's Running + +In DevOps, the first thing you do when a server feels "slow" is look at the process list. + +### 1. The `top` Command (The Live Dashboard) +Type `top` in your terminal to see a real-time list of every process. It’s like the "Task Manager" on Windows. +* **PID:** The unique "Social Security Number" for the process. +* **%CPU:** How hard the process is making the brain work. +* **%MEM:** How much space it's taking up in short-term memory. + +### 2. The `ps` Command (The Snapshot) +If you want a quick list of all processes without the live updates, use: +* `ps aux`: Shows every process running for every user on the system. +* `ps aux | grep node`: A "Pro" trick to find only your Node.js processes. + +## How to Stop a Process + +Sometimes an app "hangs" or gets stuck in an infinite loop. When that happens, you have to use the `kill` command. + +:::info The "Levels" of Killing +Not all "kills" are the same. You send a **Signal** to the process: +* **SIGTERM (15):** The "Polite" kill. It tells the app, "Please save your work and close down." (`kill PID`) +* **SIGKILL (9):** The "Angry" kill. It forces the app to stop immediately. Use this as a last resort. (`kill -9 PID`) +::: + +## Foreground vs. Background + +At **CodeHarborHub**, you don't want to keep your terminal window open just to keep a script running. + +1. **Foreground:** The process takes over your terminal. You can't type anything else until it's done. +2. **Background:** You add an `&` at the end of your command (e.g., `python script.py &`). The script runs "behind the scenes," and you can keep using your terminal. + +## The Life-Saver: `systemd` + +In a professional environment, we don't manually start and stop apps. We use **systemd**. It is a manager that: +* Starts your app automatically when the server turns on. +* **Restarts** your app if it crashes. +* Keeps logs of everything your app prints. + +### Common Systemd Commands: +* `sudo systemctl start nginx`: Start the web server. +* `sudo systemctl status nginx`: See if the server is healthy. +* `sudo systemctl restart nginx`: Apply new settings by restarting. + +## Summary Checklist +* [x] I understand that a **Process** is a running instance of a program. +* [x] I can identify a process by its **PID**. +* [x] I know how to use `top` and `ps aux` to monitor the server. +* [x] I understand when to use `kill` vs `kill -9`. +* [x] I know that `systemd` is used for "Production" level management. + +:::info Why this matters for DevOps +Imagine you are hosting **CodeHarborHub** and the site goes down. +1. You SSH into the server. +2. You run `top` and see that a "Log Collector" script is using 100% CPU. +3. You `kill` that process. +4. The site is back up. +**You just saved the day!** +::: \ No newline at end of file