course ch2 m4 updates

This commit is contained in:
marcel-dempers 2025-01-02 21:52:51 +11:00
parent 02694b639d
commit 4bded66d61
2 changed files with 38 additions and 14 deletions

View File

@ -62,7 +62,7 @@ You will build the ultimate foundation and be equipped to make more informed dec
## 📖 Table of Contents ## 📖 Table of Contents
* [Chapter 1: Source Control & GIT](./chapters/chapter-1-source-control-git/README.md) * [Chapter 1: Source Control & GIT](./chapters/chapter-1-source-control-git/README.md)
* 🚧[Chapter 2: Operating Systems](./chapters/chapter-2-operating-systems/README.md) * [Chapter 2: Operating Systems](./chapters/chapter-2-operating-systems/README.md)
* 🚧[Chapter 3: Monitoring](./chapters/chapter-3-monitoring/README.md) * 🚧[Chapter 3: Monitoring](./chapters/chapter-3-monitoring/README.md)
* 🚧[Chapter 4: Web Servers](./chapters/chapter-4-web-servers/README.md) * 🚧[Chapter 4: Web Servers](./chapters/chapter-4-web-servers/README.md)
* 🚧[Chapter 4.1: Web Server Monitoring](./chapters/chapter-4.1-web-server-monitoring/README.md) * 🚧[Chapter 4.1: Web Server Monitoring](./chapters/chapter-4.1-web-server-monitoring/README.md)

View File

@ -34,9 +34,9 @@ So you understand the difference between Terminals and Shells </br>
## Types of Terminals ## Types of Terminals
On windows as we can see there is a built-in terminal that can run either Powershell or CMD Command Prompt. Windows also launched a newer terminal called [Windows Terminal](https://github.com/microsoft/terminal) which is available on Github. </br> On Windows as we can see there is a built-in terminal that can run either Powershell or CMD Command Prompt. Windows also launched a newer terminal called [Windows Terminal](https://github.com/microsoft/terminal) which is available on Github. </br>
On Windows, we get different terminals like GNOME Terminal, Terminology, Terminator and more </br> On Linux, we get different terminals like GNOME Terminal, Terminology, Terminator and more </br>
In this demo, I will show you an example of Windows Terminal and Terminator on Linux </br> In this demo, I will show you an example of Windows Terminal and Terminator on Linux </br>
@ -63,8 +63,8 @@ When you want to automate something, you gather and stitch together all the comm
Some examples may include: Some examples may include:
* We could stitch together commands that check if folder structures exists or not and create them if they dont exist. Then automatically create configuration files with default settings in them to setup an application * We could stitch together commands that check if folder structures exist or not and create them if they don't exist. Then automatically create configuration files with default settings in them to setup an application
* We could stitch together commands that makes a copy of important files and folders on our system, compress them as a "zip" file and upload it to remote storage to create an automated backup process. * We could stitch together commands that make a copy of important files and folders on our system, compress them as a "zip" file and upload it to remote storage to create an automated backup process.
## Command Line Structure ## Command Line Structure
@ -74,7 +74,7 @@ Generally, all or most commands conform to some standard. </br>
### Executable ### Executable
For example, all command lines start with some form of executable or binary. </br> For example, all command lines start with some form of executable or binary. </br>
A binary of executable is a program or script. </br> A binary executable is a program or script. </br>
For example in our Introduction to `git` , we learned about the `git` command. In that case `git` is the executable. For example in our Introduction to `git` , we learned about the `git` command. In that case `git` is the executable.
So we start off our command with the executable: So we start off our command with the executable:
@ -86,7 +86,7 @@ git
### Commands and Subcommands ### Commands and Subcommands
An executable may have commands, and commands by have subcommands. </br> An executable may have commands, and commands by have subcommands. </br>
However, some executable may have no commands. This is generally true for command line executables where they generally only perform one thing, like `ls` However, some executables may have no commands. This is generally true for command line executables where they generally only perform one thing, like `ls`
If you run `ls --help` , you'll notice the usage: If you run `ls --help` , you'll notice the usage:
@ -118,11 +118,11 @@ git push
### Arguments, Options, Flags or Parameters ### Arguments, Options, Flags or Parameters
When a command needs inputs, the command may require arguments, options, flags or parameters. </br> When a command needs inputs, the command may require arguments, options, flags or parameters. </br>
Those terms are often used interchangably. </br> Those terms are often used interchangeably. </br>
Command line options generally start with dashes. </br> Command line options generally start with dashes. </br>
Generally a single `-` character indicates a short abbreviated form of an option and a double `--` is a long form version of the same option. </br> Generally a single `-` character indicates a short abbreviated form of an option and a double `--` is a long form version of the same option. </br>
For example, `-h` and `--help` generally mean the same thing, but one is abbreviated, so shorter to type out and the other is longer, which means its more descriptive but longer to type out. </br> For example, `-h` and `--help` generally mean the same thing, but one is abbreviated, so shorter to type out and the other is longer, which means it's more descriptive but longer to type out. </br>
If we take a look at `git` that we learned about: If we take a look at `git` that we learned about:
@ -138,9 +138,9 @@ Above, `-m` stands for message.
- For example, `echo "hello"`, or `echo $HOME` - For example, `echo "hello"`, or `echo $HOME`
* `cat` : This command displays file contents. It can display one or multiple files contents and concatenates them * `cat` : This command displays file contents. It can display one or multiple files contents and concatenates them
- For example `cat <filename>` - For example `cat <filename>`
* `ls` : Allos to list contents of a directory * `ls` : Allows to list contents of a directory
* `cd` : Change working directory * `cd` : Change working directory
* `pwd` : Writes the full path of the currend working directory to the screen * `pwd` : Writes the full path of the current working directory to the screen
* `touch` : Creates a file without content * `touch` : Creates a file without content
* `nano` : Starts a simple Linux text editor * `nano` : Starts a simple Linux text editor
* `mkdir` : Create a directory * `mkdir` : Create a directory
@ -156,9 +156,33 @@ Above, `-m` stands for message.
* `wget` : Downloads files from the web * `wget` : Downloads files from the web
* `curl` : Create and send a Web request to a server * `curl` : Create and send a Web request to a server
## Command inputs and outputs ## Command inputs, outputs and redirection
We can capture outputs of a command. </br> We can capture outputs of a command. </br>
This becomes useful for two main reasons. </br>
Firstly, we can use the output of one command as input for another. Technically this allows us to chain commands together. </br>
This is useful in automation and scripting when taking output of one command execution and passing it as input to another </br>
Secondly, capturing output of a command can be useful to store in a file for troubleshooting purposes or any other reason. </br>
For example, a command's output may be quite large to analyze in a terminal window and may be useful to analyze as a file which we can open in an editor such as Visual Studio Code. </br>
### Command pipe
To capture output of one command and send it as input to another command, we can use the "pipe" character. </br>
This often is referred to "piping" output to another command in command line </br>
For example, we can use `cat` to output file contents and then `|` it to `grep` to search that content for a given string pattern. </br>
This often helps looking for something in a large file. </br>
```
cat <filename> | grep <pattern>
```
### Command redirection
To redirect command line output to a file, we can use the command redirection character `>`
For example when running `ls`, it outputs to the terminal. </br> For example when running `ls`, it outputs to the terminal. </br>
We can capture that output by placing the `>` character after the command followed by a filename that we want to pass output to </br> We can capture that output by placing the `>` character after the command followed by a filename that we want to pass output to </br>