Skip to content

Commit

Permalink
Merge pull request #1753 from fireship-io/linux-course
Browse files Browse the repository at this point in the history
Linux course
  • Loading branch information
codediodeio authored Jul 2, 2024
2 parents c1a83ac + b206669 commit a8472da
Show file tree
Hide file tree
Showing 54 changed files with 1,305 additions and 3 deletions.
5 changes: 5 additions & 0 deletions app/stores/products.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
export const products = {
'linux': {
id: 'linux',
price: 'price_1PY9DmBF7AptWZlcpkAbgZlP',
amount: 20,
},
'stripe-saas': {
id: 'stripe-saas',
price: 'price_1OyecaBF7AptWZlc4nRFI3Ei',
Expand Down
2 changes: 0 additions & 2 deletions app/util/firebase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ export async function callUserAPI<T>(data: UserAPIData): Promise<T> {
const { getFunctions, httpsCallable } = await import('firebase/functions');
const functions = getFunctions();
// connectFunctionsEmulator(functions, 'localhost', 5001); // DEV only

const res = await httpsCallable(functions, 'userAPI')(data);

// Capture GA event for all user initiated backend API calls
Expand All @@ -155,7 +154,6 @@ export async function callUserAPI<T>(data: UserAPIData): Promise<T> {
console.log(error);
toast.set({ message: error?.message ?? 'Unknown Error. Contact hello@fireship.io for help', type: 'error' });
GAEvent('exception', {
location: 'callUserAPI',
description: error?.message,
});
}
Expand Down
2 changes: 1 addition & 1 deletion bin/img.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { readdirSync, rmSync } from 'fs';
import { exec } from 'child_process';

// npx @squoosh/cli --webp auto ./4.jpg
const dir = './content/courses/sveltekit/img/prizes/';
const dir = './content/courses/linux/img/prizes/';
// const dir = './static/img/testimonial/';
const files = readdirSync(dir)
files.forEach(file => {
Expand Down
60 changes: 60 additions & 0 deletions content/courses/linux/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
lastmod: 2024-06-15T10:23:30-09:00
title: Linux Full Course
description: Learn Linux and start self-hosting your apps like an open-source freedom fighter
weight: 0
type: courses
author: Jeff Delaney
vimeo: 974286249
tags:
- linux
- pro

stack:
- ubuntu
- pocketbase
- nextjs
---

**Linux - The Full Course** is a hands-on tutorial where you will learn the powerful skill of administering a Linux system to self-host your own code on a Virtual Private Server (VPS).

## What will I learn?

- 🐧 Everything you need to be productive with Linux
- 🚀 Essential Linux concepts explained in 100 seconds
- 📂 File system navigation, permissions, and management
- 👨‍💻 System administration basics and user management
- 📜 Build complex scripts with Bash
- 🖥️ Understand process management and system monitoring
- 🔥 Firewalls and network configuration
- 🤔 How to choose a VPS provider
- ⚙️ Automate services with systemd
- 🌟 Deploy your own web server Nginx
- 🧊 Mount block storage for self-hosted databases
- 🔐 Linux security fundamentals

## 🛠️ What will I build?

You will set up and configure a **Complete Linux Server Environment** for a self-hosted web application inspired by real-world scenarios - you can use the project code on GitHub or bring your own application. The primary goal is to leverage Linux's powerful command-line interface to teach you a variety of system administration and automation tasks. By the end of the course, you will be a certified Linux giga chad!

### 💻 Try it out!

Access our virtual Linux environment and give it a test drive before you enroll. It includes a fully functional Linux system where you can practice commands, write scripts, and more:

<div>
<a href="https://linux.fireship.app" class="btn btn-orange">Self-hosted demo app</a>
</div>

## 🤔 Is this Course Right for Me?

<div class="box box-blue">
This course is beginner to intermediate level 🟦 and expects some basic familiarity with computers. The content is fast-paced and hands-on, then dives into more complex self-hosting techniques on a live Linux server.
</div>

## When was the course last updated?

<span class="tag tag-sm tag-pro">Updated July 1st, 2024</span> <span class="tag tag-sm tag-linux">Ubuntu 24.04 LTS</span>

## How do I enroll

The first few lessons are *free*, so just give it a try. When you reach a paid module, you will be asked to pay for a single course or upgrade to PRO.
107 changes: 107 additions & 0 deletions content/courses/linux/basics-10-commands.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
---
title: 10 Essential Commands
description: Ten Linux commands and tricks you absolutely must know
weight: 10
lastmod: 2024-06-20T11:11:30-09:00
draft: false
vimeo: 973045131
emoji: 💪
video_length: 6:54
chapter_start: Terminal Mastery
quiz: true
free: true
---

<quiz-modal options="-a:-p:-r:-force" answer="-p" prize="1">
<h6>Which flag would be used with <code>mkdir foo/bar/baz</code> to create all missing parent directories</h6>
</quiz-modal>

## Ten Linux Comands && Useful Tricks

**ls**

List all files, but sorted by size and print the size.

{{< file "cog" "command line" >}}
```bash
ls -sS
```

**cd**

Move into the previous directory

{{< file "cog" "command line" >}}
```bash
cd -
```

**pwd**

Print the current working directory

{{< file "cog" "command line" >}}
```bash
pwd
```

**echo**

Print a value to the stardard output

{{< file "cog" "command line" >}}
```bash
echo "Hi Mom!"
```

**mkdir**

Make a deeply nested directory and all it's parent directories

{{< file "cog" "command line" >}}
```bash
mkdir -p new_directory/subdirectory
```
**touch**

Create a new file

{{< file "cog" "command line" >}}
```bash
touch diary.txt
```
**rm**



{{< file "cog" "command line" >}}
```bash
rm diary.txt
rm -rf directory_to_remove # use carefully
```

**cat**

Read a file

{{< file "cog" "command line" >}}
```bash
cat diary.txt
```
**cp**

Copy a file or directory recursively

{{< file "cog" "command line" >}}
```bash
cp -r source_dir destination_dir
```

**mv**

Move or rename a file

{{< file "cog" "command line" >}}
```bash
mv diary.txt useless-ramblings.txt
```
38 changes: 38 additions & 0 deletions content/courses/linux/basics-bash-config.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
title: Bash Config
description: How to make your Linux terminal look cool
weight: 16
lastmod: 2024-06-20T11:11:30-09:00
draft: false
vimeo: 973161558
emoji: 🎨
video_length: 2:31
---

## 7 Examples of PS1 Customization

Make your terminal prompt look cool like a true linux hacker by trying these examples:

{{< file "cog" "~/.bashrc" >}}
```bash
# Jeff's favorite prompt
PS1='\[\e[01;35m\]\W\[\e[m\] ❯ '

# Minimal
PS1='\u:\W $ '

# Minimal with git branch
PS1='\W$(__git_ps1 " (%s)") $ '

# Two line prompt with git branch
PS1='\n\[\033[01;32m\]\u@\h\[\033[00m\] \[\033[01;34m\]\w\[\033[00m\] $(__git_ps1 "(%s)")\n\$ '

# Colorful prompt
PS1='\[\033[01;32m\]\u\[\033[00m\]@\[\033[01;36m\]\h\[\033[00m\] \[\033[01;34m\]\w\[\033[00m\] \[\033[01;33m\][\t]\[\033[00m\] \[\033[01;31m\]$(if [[ $? == 0 ]]; then echo "✓"; else echo "✗"; fi)\[\033[00m\]\n\$ '

# Retro Style
PS1='\[\033[01;32m\][\[\033[01;36m\]\u\[\033[01;32m\]@\[\033[01;36m\]\h\[\033[01;32m\]] \[\033[01;34m\]\w\[\033[00m\] \$ '

# Customized based on time of day with emojis
PS1='$(if [ $(date +%H) -lt 12 ]; then echo "🌅"; elif [ $(date +%H) -lt 18 ]; then echo "☀️"; else echo "🌙"; fi) \[\033[01;32m\]\u\[\033[00m\] in \[\033[01;34m\]\w\[\033[00m\] \$ '
```
52 changes: 52 additions & 0 deletions content/courses/linux/basics-cron.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
title: Cron Jobs
description: Run background processes on a schedule with Cron
weight: 20
lastmod: 2024-06-15T11:11:30-09:00
draft: false
vimeo: 973160667
emoji:
video_length: 4:08
---

## Edit a Cron Schedule

I highly recommend using tools like [Crontab Guru](https://crontab.guru/#20_4_*_*_5) for generating cron schedules.


## How to Start a Cron Job in Linux

Create a basic bash script to run in the background:

{{< file "terminal" "command line" >}}
```bash
nano hello.sh

# echo "hello world!"

realpath hello.sh # get the full path of the file
```

Start the cron service and edit the crontab file:

{{< file "terminal" "command line" >}}
```bash
sudo service cron start

crontab -e
```

Edit the crontab file with the path to your bash script:

```
* * * * * /mnt/d/apps/linux-playground/hello.sh
```

Verify that the cron job is running:

{{< file "terminal" "command line" >}}
```bash
crontab -l
sudo grep CRON /var/log/syslog
sudo grep CRON /var/log/cron
```
34 changes: 34 additions & 0 deletions content/courses/linux/basics-file-system.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
title: The File System
description: Every Linux directory explained
weight: 11
lastmod: 2024-06-20T11:11:30-09:00
draft: false
vimeo: 973045264
emoji: 🗃️
video_length: 4:02
quiz: true
---

<quiz-modal options="/etc/log:/home/apps/log:/log:/var/log" answer="/var/log" prize="2">
<h6>You wrote an application and want to host it on your server. Where should you save your log files?</h6>
</quiz-modal>

## The Linux File System Cheat Sheet

{{< figure src="/courses/linux/img/linux-file-system.png" caption="Linux file system diagram" >}}

- **/ (root):** The primary hierarchy for the entire file system.
- **/boot:** Contains files needed to boot the system.
- **/dev:** Contains device files that represent hardware components.
- **/usr:** Contains user-related programs and data.
- **/bin:** Contains essential user binaries (commands).
- **/sbin:** Contains essential system binaries (commands).
- **/home:** Contains home directories for users.
- **/lib:** Contains essential shared libraries for system binaries.
- **/tmp:** Contains temporary files.
- **/var:** Contains variable data like logs and caches.
- **/etc:** Contains system-wide configuration files.
- **/proc:** Contains virtual files that represent system and process information.
- **/usr/local:** Contains user-installed software.
- **/home/bob** and **/home/alice:** Home directories for users Bob and Alice.
50 changes: 50 additions & 0 deletions content/courses/linux/basics-grep.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
title: Grep && Sed
description: Advanced text searching and manipulation techniques
weight: 18
lastmod: 2024-06-20T11:11:30-09:00
draft: false
vimeo: 973161216
emoji: 🔎
video_length: 3:08
quiz: true
---

<quiz-modal options="Universe:Mom:Hi Mom:empty string" answer="Universe" prize="8">
<h6>What does the following command do?</h6>
<p><code>echo "Hi Mom" | grep -o "Mom" | sed 's/Mom/Universe/'</code></p>
</quiz-modal>

## Searching for Text with Grep

Search through a single file:

{{< file "cog" "command line" >}}
```bash
grep "mom" file.txt
```

Search through a directory recursively:

{{< file "cog" "command line" >}}
```bash
grep -r "mom" .
```

## Edit text with Sed

Run a find and replace operation with sed:

{{< file "cog" "command line" >}}
```bash
sed 's/mom/dad' file.txt
```


## Bonus Video

Learn more regex to match advanced patterns.

<div class="vid-center">
{{< youtube sXQxhojSdZM >}}
</div>
Loading

0 comments on commit a8472da

Please sign in to comment.