From 3bae42575f6c2e77846f18e2d277f531c43d23fe Mon Sep 17 00:00:00 2001 From: waldek Date: Fri, 25 Feb 2022 00:01:13 +0100 Subject: [PATCH] full outline and TOC --- essential/readme.md | 233 +++++++++++++++++++++++++++++++++++++++++++- readme.md | 128 +++++++++++++++++++++--- 2 files changed, 344 insertions(+), 17 deletions(-) diff --git a/essential/readme.md b/essential/readme.md index 903970c..1f85e10 100644 --- a/essential/readme.md +++ b/essential/readme.md @@ -605,6 +605,13 @@ When you think about it it does make sense because at the end of the day the com So when you execute a script each line of code is converted to machine instructions on the spot. This makes scripts easier to write but slower at execution. +## Note on file extensions + +Linux does not rely as much on file extensions as windows does. +We could even say it often does not care about them. +Due to the decentralized nature of Linux development, some programs *do* care about them while others don't. +It's a bit of hit and miss but I advise you to read [this](https://askubuntu.com/questions/803434/do-file-extensions-have-any-purpose-in-linux) post on AskUbuntu for a more detailed explanation. + # More about paths The prompt in our terminal tells us who we are, on which machine, and **where** we are located. @@ -1196,12 +1203,236 @@ waldek@hellodebian:~$ **Read** some manual pages on the commands we've seen until now. **Apply** some options you read about in the manual to experiment with said programs. -# Creating and modifying +# Creating, modifying and deleting + +We've seen how to navigate our filesystem and how to list files and directories at certain locations. +Now let's learn how to add, modify and remove files and directories. ## Directories +The main tool to create directories is `mkdir`. +It's usage is pretty simple, it will create a directory at the location you specify as argument. +This location can be absolute or relative. +By default it will **not** create parent directories if needed but we can force it to do so with the `-p` flag. + +``` +waldek@hellodebian:~$ ls +Desktop Documents Downloads Music Pictures Public Templates Videos +waldek@hellodebian:~$ mkdir website +waldek@hellodebian:~$ ls +Desktop Documents Downloads Music Pictures Public Templates Videos website +waldek@hellodebian:~$ ls website/ +waldek@hellodebian:~$ mkdir website/page_one/assets +mkdir: cannot create directory ‘website/page_one/assets’: No such file or directory +waldek@hellodebian:~$ mkdir -p website/page_one/assets +waldek@hellodebian:~$ ls -R website/ +website/: +page_one + +website/page_one: +assets + +website/page_one/assets: +waldek@hellodebian:~$ +``` + +The counterpart to `mkdir` is `rmdir` which can be used to remove **empty** directories. +As it can only remove empty directories it's not used that much but it's worth knowing it exists. + +``` +waldek@hellodebian:~$ rmdir website/ +rmdir: failed to remove 'website/': Directory not empty +waldek@hellodebian:~$ rmdir website/page_one/ +rmdir: failed to remove 'website/page_one/': Directory not empty +waldek@hellodebian:~$ rmdir website/page_one/assets/ +waldek@hellodebian:~$ rmdir website/page_one/ +waldek@hellodebian:~$ rmdir website/ +waldek@hellodebian:~$ ls +Desktop Documents Downloads Music Pictures Public Templates Videos +waldek@hellodebian:~$ +``` + +To remove directories that have subdirectories or files in them we need to use an other program, `rm` but with a specific flag `-r`. +It works as such. + +``` +waldek@hellodebian:~$ mkdir -p website/page_one/assets +waldek@hellodebian:~$ rm website/ +rm: cannot remove 'website/': Is a directory +waldek@hellodebian:~$ rm -r website/ +waldek@hellodebian:~$ ls +Desktop Documents Downloads Music Pictures Public Templates Videos +waldek@hellodebian:~$ +``` + +**There is no trash or recycle bin on the command line! Removed is removed so think before you hit enter.** + ## Files +We can create empty files with the `touch` command. +It's worth pointing out that using `touch` to create files is not it's main purpose. +Reading the manual the fact that it creates files is kind of an extra feature. +Non the less, it's widely used to create files. + + +``` +TOUCH(1) User Commands TOUCH(1) + +NAME + touch - change file timestamps + +SYNOPSIS + touch [OPTION]... FILE... + +DESCRIPTION + Update the access and modification times of each FILE to the current time. + + A FILE argument that does not exist is created empty, unless -c or -h is supplied. + + A FILE argument string of - is handled specially and causes touch to change the times of the file associated with standard output. + + Mandatory arguments to long options are mandatory for short options too. + +``` + +In practice it works as follows. +We can create files with `touch` and delete them with `rm`. +For deleting files we don't need any extra flags as opposed to directories. + +``` +waldek@hellodebian:~$ mkdir -p website/page_one/assets +waldek@hellodebian:~$ ls website/ +page_one +waldek@hellodebian:~$ touch website/index.html +waldek@hellodebian:~$ ls website/ +index.html page_one +waldek@hellodebian:~$ file website/index.html +website/index.html: empty +waldek@hellodebian:~$ rm website/index.html +waldek@hellodebian:~$ ls website/ +page_one +waldek@hellodebian:~$ file website/index.html +website/index.html: cannot open `website/index.html' (No such file or directory) +waldek@hellodebian:~$ +``` + +What if you created the file in the wrong place? +With `mv` we can move files from one location to an other. +When you think about it, renaming is actually the *same* as moving so there is no specific program to rename files or folders. + +``` +waldek@hellodebian:~$ touch index.html +waldek@hellodebian:~$ ls +Desktop Documents Downloads index.html Music Pictures Public Templates Videos website +waldek@hellodebian:~$ mv index.html website/indexxxx.html +waldek@hellodebian:~$ ls +Desktop Documents Downloads Music Pictures Public Templates Videos website +waldek@hellodebian:~$ ls website/ +indexxxx.html page_one +waldek@hellodebian:~$ mv website/indexxxx.html website/index.html +waldek@hellodebian:~$ ls website/ +index.html page_one +waldek@hellodebian:~$ +``` + +We can also move entire directories from one location to another. + +``` +waldek@hellodebian:~$ ls +Desktop Documents Downloads Music Pictures Public Templates Videos website +waldek@hellodebian:~$ mv website/ Documents/ +waldek@hellodebian:~$ ls +Desktop Documents Downloads Music Pictures Public Templates Videos +waldek@hellodebian:~$ ls -R Documents/ +Documents/: +website + +Documents/website: +index.html page_one + +Documents/website/page_one: +assets + +Documents/website/page_one/assets: +waldek@hellodebian:~$ +``` + +Copying is done with `cp` and behaves very similar to `mv`. +For example. + +``` +waldek@hellodebian:~/Documents$ ls +website +waldek@hellodebian:~/Documents$ mv website/ website_1 +waldek@hellodebian:~/Documents$ ls +website_1 +waldek@hellodebian:~/Documents$ cp website_1/ website_2 +cp: -r not specified; omitting directory 'website_1/' +waldek@hellodebian:~/Documents$ cp -r website_1/ website_2 +waldek@hellodebian:~/Documents$ ls +website_1 website_2 +waldek@hellodebian:~/Documents$ ls -R +.: +website_1 website_2 + +./website_1: +index.html page_one + +./website_1/page_one: +assets + +./website_1/page_one/assets: + +./website_2: +index.html page_one + +./website_2/page_one: +assets + +./website_2/page_one/assets: +waldek@hellodebian:~/Documents$ +``` + ### `nano` ### `vi` and `vim` + +# Exercise + +The only way to learn `vim` is to *use* it. +Luckily `vim-nox` comes with a dedicated *program* to learn it called `vimtutor`. +It's actually a text file that you open up in `vim` where you just need to **read** and **execute** what you've read. +Enjoy! + +# Finding stuff + +## Finding files + +## Searching inside files + +## Wildcards and regular expressions + +# Pipes and redirects + +# Users + +## Adding and removing users + +## Switching user + +# Permissions + +## Octal number system + +## Changing permissions + +## Changing ownership + +# Remote control of a server + +## History + +## SSH and SFTP + +# Bandit + diff --git a/readme.md b/readme.md index 63a5b70..ed6c3e9 100644 --- a/readme.md +++ b/readme.md @@ -1,37 +1,133 @@ +# About + +Table of Contents +================= + +* [Introduction to Linux](./essential/readme.md#introduction-to-linux) + * [Where does Linux originate from?](./essential/readme.md#where-does-linux-originate-from) + * [Who is behind this project?](./essential/readme.md#who-is-behind-this-project) + * [What is the deal with 'GNU-slash-Linux'?](./essential/readme.md#what-is-the-deal-with-gnu-slash-linux) + * [Where can you get some Linux?](./essential/readme.md#where-can-you-get-some-linux) + * [Debian](./essential/readme.md#debian) +* [How to create a virtual machine](./essential/readme.md#how-to-create-a-virtual-machine) +* [Breakdown of the Debian installation](./essential/readme.md#breakdown-of-the-debian-installation) +* [Exercise](./essential/readme.md#exercise) +* [Quick look at an idle system](./essential/readme.md#quick-look-at-an-idle-system) +* [Package managers](./essential/readme.md#package-managers) + * [Graphical installation](./essential/readme.md#graphical-installation) + * [Command line installation](./essential/readme.md#command-line-installation) + * [Adding a secondary desktop environment](./essential/readme.md#adding-a-secondary-desktop-environment) +* [Changing the runlevel](./essential/readme.md#changing-the-runlevel) +* [Exercise](./essential/readme.md#exercise-1) +* [Guest additions](./essential/readme.md#guest-additions) +* [Introduction to the command line](./essential/readme.md#introduction-to-the-command-line) + * [Compiled vs interpreted](./essential/readme.md#compiled-vs-interpreted) + * [Note on file extensions](./essential/readme.md#note-on-file-extensions) +* [More about paths](./essential/readme.md#more-about-paths) + * [Absolute and relative paths](./essential/readme.md#absolute-and-relative-paths) + * [root and / and /root are not the same thing](./essential/readme.md#root-and---and-root-are-not-the-same-thing) +* [Exercise](./essential/readme.md#exercise-2) +* [A pit stop to review what we've learned so far](./essential/readme.md#a-pit-stop-to-review-what-weve-learned-so-far) +* [Arguments and flags](./essential/readme.md#arguments-and-flags) +* [Getting help](./essential/readme.md#getting-help) + * [Options](./essential/readme.md#options) + * [Manuals](./essential/readme.md#manuals) +* [Exercise](./essential/readme.md#exercise-3) +* [Creating, modifying and deleting](./essential/readme.md#creating-modifying-and-deleting) + * [Directories](./essential/readme.md#directories) + * [Files](./essential/readme.md#files) + * [nano](./essential/readme.md#nano) + * [vi and vim](./essential/readme.md#vi-and-vim) +* [Exercise](./essential/readme.md#exercise-4) +* [Finding stuff](./essential/readme.md#finding-stuff) + * [Finding files](./essential/readme.md#finding-files) + * [Searching inside files](./essential/readme.md#searching-inside-files) + * [Wildcards and regular expressions](./essential/readme.md#wildcards-and-regular-expressions) +* [Pipes and redirects](./essential/readme.md#pipes-and-redirects) +* [Users](./essential/readme.md#users) + * [Adding and removing users](./essential/readme.md#adding-and-removing-users) + * [Switching user](./essential/readme.md#switching-user) +* [Permissions](./essential/readme.md#permissions) + * [Octal number system](./essential/readme.md#octal-number-system) + * [Changing permissions](./essential/readme.md#changing-permissions) + * [Changing ownership](./essential/readme.md#changing-ownership) +* [Remote control of a server](./essential/readme.md#remote-control-of-a-server) + * [History](./essential/readme.md#history) + * [SSH and SFTP](./essential/readme.md#ssh-and-sftp) +* [Bandit](./essential/readme.md#bandit) + # Planning ## Essential ### Day 1 -* Introduction to Linux and it's history -* How to create a virtual machine -* Breakdown of the Debian installation -* Install your own graphical Debian installation with gnome as graphical interface -* Explain the concept of a package manager -* Install VLC via the graphical software tool -* Introduction to the command line -* Install `htop` via `apt` -* Add a secondary desktop environment (XFCE or LXDE) via `tasksel` and explore it's footprint -* Disable the window manager via `systemctl` -* Install a minimal Debian machine and add some software to it (htop, bmon, ...) as an exercise +* [Introduction to Linux](./essential/readme.md#introduction-to-linux) + * [Where does Linux originate from?](./essential/readme.md#where-does-linux-originate-from) + * [Who is behind this project?](./essential/readme.md#who-is-behind-this-project) + * [What is the deal with 'GNU-slash-Linux'?](./essential/readme.md#what-is-the-deal-with-gnu-slash-linux) + * [Where can you get some Linux?](./essential/readme.md#where-can-you-get-some-linux) + * [Debian](./essential/readme.md#debian) +* [How to create a virtual machine](./essential/readme.md#how-to-create-a-virtual-machine) +* [Breakdown of the Debian installation](./essential/readme.md#breakdown-of-the-debian-installation) +* [Exercise](./essential/readme.md#exercise) +* [Quick look at an idle system](./essential/readme.md#quick-look-at-an-idle-system) +* [Package managers](./essential/readme.md#package-managers) + * [Graphical installation](./essential/readme.md#graphical-installation) + * [Command line installation](./essential/readme.md#command-line-installation) + * [Adding a secondary desktop environment](./essential/readme.md#adding-a-secondary-desktop-environment) +* [Changing the runlevel](./essential/readme.md#changing-the-runlevel) +* [Exercise](./essential/readme.md#exercise-1) ### Day 2 -* Install the guest additions to the main Debian machine +* [Guest additions](./essential/readme.md#guest-additions) +* [Introduction to the command line](./essential/readme.md#introduction-to-the-command-line) + * [Compiled vs interpreted](./essential/readme.md#compiled-vs-interpreted) + * [Note on file extensions](./essential/readme.md#note-on-file-extensions) +* [More about paths](./essential/readme.md#more-about-paths) + * [Absolute and relative paths](./essential/readme.md#absolute-and-relative-paths) + * [root and / and /root are not the same thing](./essential/readme.md#root-and---and-root-are-not-the-same-thing) +* [Exercise](./essential/readme.md#exercise-2) +* [A pit stop to review what we've learned so far](./essential/readme.md#a-pit-stop-to-review-what-weve-learned-so-far) +* [Arguments and flags](./essential/readme.md#arguments-and-flags) +* [Getting help](./essential/readme.md#getting-help) + * [Options](./essential/readme.md#options) + * [Manuals](./essential/readme.md#manuals) +* [Exercise](./essential/readme.md#exercise-3) +* [Creating, modifying and deleting](./essential/readme.md#creating-modifying-and-deleting) + * [Directories](./essential/readme.md#directories) + * [Files](./essential/readme.md#files) + * [nano](./essential/readme.md#nano) + * [vi and vim](./essential/readme.md#vi-and-vim) +* [Exercise](./essential/readme.md#exercise-4) ### Day 3 -* Install `openssh-server` +* [Finding stuff](./essential/readme.md#finding-stuff) + * [Finding files](./essential/readme.md#finding-files) + * [Searching inside files](./essential/readme.md#searching-inside-files) + * [Wildcards and regular expressions](./essential/readme.md#wildcards-and-regular-expressions) +* [Pipes and redirects](./essential/readme.md#pipes-and-redirects) +* [Users](./essential/readme.md#users) + * [Adding and removing users](./essential/readme.md#adding-and-removing-users) + * [Switching user](./essential/readme.md#switching-user) +* [Permissions](./essential/readme.md#permissions) + * [Octal number system](./essential/readme.md#octal-number-system) + * [Changing permissions](./essential/readme.md#changing-permissions) + * [Changing ownership](./essential/readme.md#changing-ownership) +* [Remote control of a server](./essential/readme.md#remote-control-of-a-server) + * [History](./essential/readme.md#history) + * [SSH and SFTP](./essential/readme.md#ssh-and-sftp) ### Day 4 -* over the wire bandit game +* [Bandit](./essential/readme.md#bandit) ### Day 5 -* over the wire bandit game -* time for Q and A +* [Bandit](./essential/readme.md#bandit) +* [Moving forward](./essential/readme.md#moving-forward) ## CCNA