--- title: WTF is Linux author: Rémi Nicole date: 2020-09-08 slide-level: 2 aspectratio: 169 theme: metropolis colortheme: owl beameroption: "show notes on second screen=right" toc: true highlightstyle: breezedark lang: en-US bibliography: ../bibliography.bib --- # The Project ## Building a Linux system manually - This is the Course (You are Here) - Using just normal commands ::: notes Hello ::: ## Building a Linux system automatically - Practical Work - Buildroot ## Why - Linux is everywhere in embedded software - Linux is everywhere in the server space # History ## 17th century to 1970s :::: columns ::: column ![Human computer at NACA [@wikimedia:human_computer]](../res/Human Computer.jpg){ height=80% } ::: ::: column ![Katherine Johnson working as a Human computer at NASA [@wikimedia:katherine_johnson_human_computer]](../res/Katherine Johnson at NASA.jpg){ height=80% } ::: :::: ::: notes - NACA: National Advisory Committee for Aeronautics - "Computer" referred to the person that did mathematical computation / verification - Verify trajectories for putting men into Earth orbit - Katherine Johnson on the right - You can watch the movie "Hidden Figures" ::: ## 1930s-1940s ![Bletchley Park Bombe [@wikimedia:bletchley_park_bombe]](../res/Bletchley Park Bombe.jpg){ width=45% height=80% } ::: notes - You can watch the movie "The Imitation Game" ::: ## 1950s ::: columns :::: column ![IBM 704 Mainframe [@wikimedia:ibm_704_mainframe]](../res/IBM 704 mainframe.jpg){ height=80% } :::: :::: column ![IBM 709 Mainframe [@ibm:ibm_709_mainframe]](../res/IBM 709 mainframe.jpg){ height=80% } :::: ::: ::: notes - There are lights and switches - Back in the day, there were used to inspect and modify memory / registries or see the executed instructions - Already two influential programming languages existed: - FORTRAN (formula translation) - Lisp - We can see: - The Operator's Console - The Central Processing Unit (CPU) - The Punch card reader - The Magnetic Tape Unit (for long term storage) - Very few "professional programmers" ::: ## 1950s---The line printer ![IBM 716 Line Printer [@ibm:ibm_716_line_printer]](../res/IBM 716 line printer.jpg){ height=80% } ::: notes - Really shaped the terminal as we know today ::: ## 1969 :::: columns ::: column Things were pricey: - Disk 180MB -> 32,000$ - Commercial compiler -> 100,000$ ::: ::: column ![Boot [@needpix:boot]](../res/boot.png){ height=80% } ::: :::: ::: notes - You could buy a very nice house for 32,000$ ::: ## 1970s---UNIX {.allowframebreaks} ![Ken Thompson (sitting) and Dennis Ritchie working together at a PDP-11 [@wikimedia:ken_thompson_dennis_ritchie]](../res/Ken Thompson and Dennis Ritchie at PDP-11.jpg){ height=67% } ::: notes - He is actually coding using the teletypewriter ::: \framebreak - Smaller, for one person[@fosdem:fifty_years_of_unix] - They actually used their own operating system - Invented C a bit later (1972) - Definitely not "free", barely "open": 160,000 $ per CPU Berkeley university made BSD out of it (was called Berkeley UNIX) ::: notes - Targeted at big companies ::: \framebreak - Same OS, different computers - Compiler took care of the difference in architecture. ::: notes - Big advantages when compared to other solutions - This made UNIX popular, and by extension the C programming language too ::: \framebreak Invented over the years by contributions: - shell (command interpreter) - pipes and filters in shell commands - Network file system (NFS) - Client/Server Windowing System - etc. ## 1980s---GNU (Richard Stallman) 1983: : GNU project annouced 1985: : Created the Free Software Foundation (helps funding) 1989: : Created GNU General Public License (GPL) Created: - Text editor (Emacs) - Compiler suite - Lots of utilities People could use these tools in different operating system ::: notes - Frustrated by his printer - Internet was widely used in academia ::: ## 1990s---POSIX - Lots of different "UNIX-like" operating system existed - There was no proper definition of what "UNIX-like" meant ## 1991--The Linux kernel (Linus Torvalds) - Just for fun - Needed a license ::: notes - Got an Intel i386 processor for Christmas - Wasn't happy with the OS (he wanted page-based memory) - Started writing a kernel, just for fun - He was 21 years old - The current situation made it possible: - Powerful "cheap" computers - "Faster" internet where you could find information about operating system and hardware architecture ::: ## 1994--Windows NT Bleurgh ::: notes - Made the "personal computer" popular - Based on a shitty technology from IBM called DOS ::: ## 1990s--Linux gaining popularity - Free - More choice for architecture - Real TCP/IP stack ::: notes - Wow, you want to connect to the internet?! ::: # Command-line primer ## Most commands ```console Copies the file "file_1.txt" into "file_2.txt" user@host:~$ cp file_1.txt file_2.txt ^^ ^^^^^^^^^^ ^^^^^^^^^^ | | | | '-------------'- arguments | '---------------------- command name (verb) ``` ## The prompt ```console ,------ username you are logged in as | | ,---- directory you are in, | | '~' means your user directory vvvv v user@host:~$ ^^^^ ^ | | | '--- '$' if you are a normal user, | '#' if you are the root user | '--- name of the machine you are on ``` ## POSIX & GNU conventions ```console ,-------------- long option / flag | | ,-- short option / flag | | vvvvvvvvvvvvvvvvvvvvv vv $ git commit --message="My commit" -S src/main.cpp ^^^ ^^^^^^ ^^^^^^^^^^^^ | | | | '----------------------------- subcommand or argument | '---------------------------------- command name ``` # The kernel ## Role Well, it depends on the kernel ::: notes Some kernel are very small, some ::: --- ![Monolithic kernel vs Microkernel](../res/OS-structure.pdf){ height=80% } ## The Linux kernel - Monolithic kernel: - Drivers are in the kernel - File-systems (ext4, fat32, etc.) are in the kernel - Lots of other things ## Communicating with the Linux kernel - System calls ::: notes - They look like functions in C code, but that's a lie, it's a hardware feature using interrupts - That's it - Kinda - We can't have one system call for everything - Different system calls for different types of hardware ::: . . . - Everything is a file ::: notes - We have special files and special file-systems - They look like files, but that's a lie - Reading / Writing to it does *not* read / write to storage - Instead it's like calling a function of the kernel - Example with `/proc/cpuinfo` ::: ## Compiling a kernel Let's do it ## Linux boot process ``` Boot loader | | loads v Linux kernel | | launches v init (first user process) | | does whatever it wants v ????? ``` ::: notes - We're not going to talk about the boot loader - Example with `htop` ::: # References