Introduction to Linux - 2021/2022

Lab 01

  • Introduction to the NSWI177 paper
  • Attendance
  • Single source of truth -> NSWI177 paper
  • Be Active
  • Questions:
    • Is there any one, who had this paper last year?
    • Who is using Linux?
    • Who is using Git?
  • Course guide:
    • No lectures
    • Before class reading & Quizzes
    • (Virtual) Labs & Practical assignment
    • Bigger assignment in the exam period
    • Highlight deadlines
    • Technical issues Gitlab Forum
    • Plagiarism
  • Motivation
    • Purpose of this course -> practical knowledge
    • Last year feedback:

      Předmět byl asi ze všech dosud zapsaných časově nejnáročnější, ale zato byl ze všech alespoň nejvíce prakticky zaměřený.

      Jeden z nejnarocnejsich predmetu druheho semestru. Latka by si zaslouzila vice casu (prednasky a cviceni). Informace byly vsak spise z tech zajimavejsich. Nechci porovnavat s konkretnimi predmety.

      Rozhodně tady bylo více praxe a hodně jsem se toho naučil. Tento předmět mě zatím bavil nejvíce hlavně kvůli té praxi.

      Zdaleka nejtěžší z nich (ať už rozsáhlostí, časovou náročností, či domácími úkoly). Oproti Prog1/2 je předmět mnohem zajímavější a prakticky využitelnější, mám pocit, že jsem si vyzkoušel Python/Ruby víc prakticky než pomalu za celý semestr Prg1+2.

      Linux byl zatím suverénně nejhorší předmět za oba semestry.

      Mnohem více časově náročný než jakýkoliv jiný předmět.

      Kdyby MFF měla showcase nejlepších předmětů, tak bych NSWI177 hledal na jeho nejviditelnějším místě! :)

      Docela mě udivuje, že jsem Linux nezačal nenávidět. Místo toho ho teď umím mnohem lépe využít.

    • Linux philosophy -> Open source & Modularity
  • Getting Linux
    • 😍 Main system
    • 😇 Dual Boot
    • 🙂 USB Disk
    • 😐 Virtual Machine
    • 🤮 WSL
  • Desktop environments -> focus to sway/i3 (i3 Reference Card)
  • Git essentials -> what it is, why we will use it
  • Using MFF GitLab -> everyone will log in now!*
  • Show GitLab CI/CD Pipeline -> how to read pipeline output
  • Graded assignments

Lab 02

  • I will be ⛷️ -> The lab will be led by Vojta Horký

Lab 03

  • Questions:
    • How was the lab 02?
    • Do you know how to submit {quizzes,tasks,issues}?
    • How much time do you spend on {quizzes,tasks}?
    • Do you have any problems?
  • Code style
    • Always write code in English, including comments and docstrings!
    • Use functions!
    • Use with context manager
    • No global variables
    • Custom exception - why not ValueError?
  • Scripts:
    • Answer Q2, Q3
    • Repeat command structure
    • What is script, hashbang and executable bit -> examples
    • Show environment PATH - explain
    • Demo with . in PATH
    • Explain cd /proc && cat cpuinfo and cd -
    • man vs help (why type is important)
    • Experimenting with shebang (follow the lab)
  • Git:
  • (Optional) Command-line Parsing (see also PS: Zpracování příkazové řádky - TL;DR — Lukáš Bařinka).
  • (Optional) Introduction to Vim (see also Vim na 20 min — Petr Hodač).
  • (Optional) Explaining if __name__ == "__main__":

Lab 04

  • Questions:
    • Do you have any problems?
    • How much time do you spend on {quizzes,tasks}?
    • How was the before reading?
  • Before reading
    • Standard input/output/error
    • Standard I/O redirection
    • Exit code
  • I/O redirection
    • Merge two files
    • Appending with >>
    • Utility tee
    • Input redirection
    • Generic redirection
    • Special files /dev/full, /dev/null, /dev/random, /dev/zero
  • Pipes
    • What it is?
    • Differences between cut file vs <file cut
  • Using && and ||
    • Exit codes
    • Explain what it does
    • Fast failing set -ueo pipefail
  • Shell customization
  • Examples

Lab 05

  • Questions:
    • Do you have any problems?
    • How much time do you spend on {quizzes,tasks}?
    • How was the before reading?
  • Before reading
    • Shell variables (export, env)
    • Bash arithmetic
    • env in hashbang
    • Control flow (for, if, !, switch)
  • Shell Scripting
    • Variables
    • BASH parameter expansions (${parameter:-})
    • shopt -s nullglob and shopt -s failglob
    • Command substitution
    • Redirection of bigger shell portions
    • read command + how to read from file (More details)
    • Script parameters
  • Exercises

Lab 06

  • Questions:
    • Do you have any problems?
    • How much time do you spend on {quizzes,tasks}?
    • How was the before reading?
  • Shell Scripting
    • Misunderstanding from previous lab
    • geopt - type the example with :
    • Functions
    • Subshells and variable scoping
    • Here documents and here string
    • Bash [[ ]] (More details)
    • Bash arrays (More details)
    • (Optional) Variable IFS (More details)
  • Exercises

Lab 07

  • Questions:
    • Do you have any problems?
    • What do you think about BASH?
  • Before reading:
    • Networking 101
    • Unix-style access rights + root access
    • chown and ls -la explanation
    • Asymmetric cryptography and SSH
  • Using SSH
    • SSH example to alpine-local
    • Explain SSH fingerprint and how to get it (~/.ssh/known_hosts)
    • SSH run one command
    • SSH Key generation + ssh-copy-id
    • SSH Config
    • scp and rsync
    • (Optional) Rsync tutorial
  • Git over SSH
    • Add SSH Key to GitLab
    • Clone repository with SSH URL
  • Networking
    • ip, ping, traceroute, mtr
  • Access Rights
    • Examples

Lab 08

  • Questions:
    • Do you have any problems?
    • What do you think about lectures? Would you like to change the style?
  • Before reading:
  • BATS
    • Motivation
    • Simple example
    • Example with custom function
    • Example with load and assets
    • Show how the tests work
    • pylint on factor.py
    • Python unittest
    • Python pytest
  • sed and grep
    • Exercise for students
    • sed multiple expressions
    • sed delete lines (More details)
    • sed script example
  • Bigger scripts
    • Exercise for students
  • (Optional) Introduction to Vim (see also Vim na 20 min — Petr Hodač).

Lab 09

  • Easter holiday
  • Before reading:
    • root user
    • sudo command
    • Package management (general)
    • Processes
    • Signals
  • sudo example
  • dnf example (search and install)
  • htop example
  • (optional) :(){ :|:& };: (Fork Bomb Explanation)
  • Signals
    • Example in python
    • Example in bash
  • SIGINT is the interrupt signal. The terminal sends it to the foreground process when the user presses <C-c>. The default behavior is to terminate the process, but it can be caught or ignored. The intention is to provide a mechanism for an orderly, graceful shutdown.
  • SIGQUIT is the dump core signal. The terminal sends it to the foreground process when the user presses <C-\>. The default behavior is to terminate the process and dump core, but it can be caught or ignored. The intention is to provide a mechanism for the user to abort the process. You can look at SIGINT as “user-initiated happy termination” and SIGQUIT as “user-initiated unhappy termination.”
  • SIGTERM is the termination signal. The default behavior is to terminate the process, but it also can be caught or ignored. The intention is to kill the process, gracefully or not, but to first allow it a chance to cleanup.
  • SIGKILL is the kill signal. The only behavior is to kill the process, immediately. As the process cannot catch the signal, it cannot cleanup, and thus this is a signal of last resort.
  • SIGSTOP is the pause signal. The only behavior is to pause the process; the signal cannot be caught or ignored. The shell uses pausing (and its counterpart, resuming via SIGCONT) to implement job control.

Lab 10

  • Questions:
    • Do you have any problems?
    • What about homework?
  • Before reading:
    • Storage management (mounts, disk images)
    • Services (daemon, logs)
  • File management
    • tar, apack examples
    • mount and udisksctl examples
    • Note about repairing corrupted disks
    • Disk usage example
  • SSH port forwarding
    • Example
    • Note about Reverse port forwarding
  • Network Manager (students’ exercise)
    • Note about nmtui and nmcli
    • Note about nc
    • Example nmap
  • Systemd (students’ exercise)
  • Printing and Scaning (students’ exercise)
  • Periodically running tasks Crone (students’ exercise)

Lab 11

  • Questions:
    • Do you have any problems?
  • InstallFest 2022
  • Before reading:
    • Virtual environment motivation (system wide, user wide, venv)
    • PyPI vs Linux Distro repositories
  • Virtual environment
    • Example with timestamp2iso.py
    • Installing Python packages with pip
    • Dependency versioning
    • Storing dependencies
  • Packaging Python Projects
    • Show VCS pip support
    • Python Package Directory Structure
    • Building Python Package
    • Publishing Python Package
  • (Optional) Show poetry

Lab 12

  • I will be 🏖️+ 🏐 -> The lab will be led by Vojta Horký

Lab 13

  • Questions:
    • Do you have any problems?
    • What about the previous lab?
  • Before reading:
    • pandoc examples
    • Build systems in general
  • xargs
    • Multiple rm execution
    • Single rm execution
  • find
    • Follow examples in course page
  • make
    • Motivation for having Makefile and show its usage in 13/make (remove .PHONY)
    • Example Makefile
    • Explain .PHONY
    • Students’ Exercises
    • Improvements (automatic variables, git clean, make help)
  • (Optional) Example Slides Template
  • (Optional) Show git ignore from gitignore.io.
  • (Optional) Show git lfs from git LFS.
  • (Optional) Mention bfg from bfg.

Lab 14

  • Questions:
    • Do you have any problems?
  • Before reading:
    • Container technology introduction
    • Docker vs Podman (not really)
    • Image vs Container
    • Image Stacking
    • Alpine distribution
    • GitLab CI
  • Podman
    • Warning Python Docker builds 50x slower
    • Running the first container
    • Pulling Images
    • Image repository
    • Containers and processes
    • Single shot runs
    • Managing container life cycle
    • Clean-up
    • Port forwarding
    • Volume mounts
  • Students’ exercise
  • GitLab CI
    • Motivation
    • timestamp2iso example
    • Master thesis example
  • (Optional) pre-commit hooks
  • Feedback:
    • What would you change on the lab style?
    • Too quick? Too slow? Too boring? Too funny?
    • What would you focus on?
    • Do you like BASH?
  • THIS IS THE END 🎉