<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="generator" content="pandoc"> <meta name="author" content="Tóth Miklós"> <meta name="dcterms.date" content="2021-03-21"> <title>Linux előadás</title> <meta name="apple-mobile-web-app-capable" content="yes"> <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui"> <link rel="stylesheet" href="https://unpkg.com/reveal.js@^4//dist/reset.css"> <link rel="stylesheet" href="https://unpkg.com/reveal.js@^4//dist/reveal.css"> <style> code{white-space: pre-wrap;} span.smallcaps{font-variant: small-caps;} span.underline{text-decoration: underline;} div.column{display: inline-block; vertical-align: top; width: 50%;} div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;} ul.task-list{list-style: none;} .display.math{display: block; text-align: center; margin: 0.5rem auto;} </style> <link rel="stylesheet" href="https://unpkg.com/reveal.js@^4//dist/theme/black.css" id="theme"> </head> <body> <div class="reveal"> <div class="slides"> <section id="title-slide"> <h1 class="title">Linux előadás</h1> <p class="author">Tóth Miklós</p> <p class="date">March 21, 2021</p> </section> <section id="pár-egyéb-hasznos-parancs" class="slide level1"> <h1>Pár egyéb hasznos parancs</h1> </section> <section id="wc" class="slide level1"> <h1><code>wc</code></h1> <ul> <li>word counter</li> <li>szavak, sorok számolása</li> </ul> <pre class="shell-session"><code>[mike@thinkyboi ~]$ echo "egy két há" | wc -w 3 [mike@thinkyboi ~]$ echo "egy két há" | wc -l 1 [mike@thinkyboi ~]$ echo "egy két há" | wc -l 3</code></pre> </section> <section id="tr" class="slide level1"> <h1><code>tr</code></h1> <ul> <li>karaktereket cserél ki vagy töröl</li> </ul> <pre class="shell-session"><code>[mike@thinkyboi ~]$ echo "almafa" | tr "a" "e" elmefe [mike@thinkyboi ~]$ echo "almafa körtefa eperfa" | tr " " "\n" almafa körtefa eperfa [mike@thinkyboi ~]$ echo "almafa" | tr -d "a" lmf</code></pre> </section> <section id="curl" class="slide level1"> <h1><code>curl</code></h1> <ul> <li>http shellből</li> <li>stdout-ra írja ki, kivéve, ha van <code>-o</code> kapcsoló</li> </ul> <pre class="shell-session"><code>[mike@thinkyboi ~]$ curl https://home.sch.bme.hu/~mikewashere/linux/eloadas.md | grep stdout % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 777 100 777 0 0 33782 0 --:--:-- --:--:-- --:--:-- 33782 - stdout-ra írja ki [mike@thinkyboi ~]$ curl https://home.sch.bme.hu/~mikewashere/linux/eloadas.md -o eloadas.md % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 777 100 777 0 0 31080 0 --:--:-- --:--:-- --:--:-- 31080 [mike@thinkyboi ~]$ </code></pre> </section> <section id="sh-fileok" class="slide level1"> <h1><code>.sh</code> fileok</h1> <ul> <li>shell automatizálása</li> <li>mintha soronként kiadnánk a parancsokat</li> </ul> </section> <section id="egy-.sh-file" class="slide level1"> <h1>egy <code>.sh</code> file</h1> <pre class="shell-session"><code>[mike@thinkyboi tmp]$ vi test.sh [mike@thinkyboi tmp]$ cat test.sh echo "ez simán működik" | cowsay curl "https://home.sch.bme.hu/~mikewashere/linux/eloadas.md" | grep "soronként" | cowsay [mike@thinkyboi tmp]$ bash test.sh _____________________ < ez simán működik > --------------------- \ ^__^ \ (oo)\_______ (__)\ )\/\ ||----w | || || % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 1596 100 1596 0 0 69391 0 --:--:-- --:--:-- --:--:-- 69391 _________________________________ / - mintha soronként kiadnánk a \ \ parancsokat / --------------------------------- \ ^__^ \ (oo)\_______ (__)\ )\/\ ||----w | || || [mike@thinkyboi tmp]$ </code></pre> </section> <section id="shebang" class="slide level1"> <h1>shebang</h1> <ul> <li>file futtatásakor a kernel meglesi mi van az elején</li> <li>el tudunk indítani scripteket programként</li> <li><code>#!<program></code></li> </ul> </section> <section id="shebang-1" class="slide level1"> <h1>shebang</h1> <pre class="shell-session"><code>[mike@thinkyboi tmp]$ vi test.sh [mike@thinkyboi tmp]$ cat test.sh #!/bin/bash echo "ez simán működik" | cowsay curl "https://home.sch.bme.hu/~mikewashere/linux/eloadas.md" | grep "soronként" | cowsay [mike@thinkyboi tmp]$ chmod +x test.sh [mike@thinkyboi tmp]$ ./test.sh _____________________ < ez simán működik > --------------------- \ ^__^ \ (oo)\_______ (__)\ )\/\ ||----w | || || % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 1596 100 1596 0 0 11319 0 --:--:-- --:--:-- --:--:-- 11319 _________________________________ / - mintha soronként kiadnánk a \ \ parancsokat / --------------------------------- \ ^__^ \ (oo)\_______ (__)\ )\/\ ||----w | || || [mike@thinkyboi tmp]$ </code></pre> </section> <section id="tűzfal" class="slide level1"> <h1>tűzfal</h1> <ul> <li>a kernel belsejében -> gyors, de low-level</li> <li>iptables</li> <li>kényelmesebb egy tűzfal-kezelő</li> </ul> </section> <section id="ufw" class="slide level1"> <h1>UFW</h1> <ul> <li>uncomplicated firewall</li> <li>egyszerű</li> </ul> <pre class="shell-session"><code>[mike@thinkyboi tmp]$ sudo ufw allow 80 Rules updated Rules updated (v6) [mike@thinkyboi tmp]$ sudo ufw allow https Rules updated Rules updated (v6) [mike@thinkyboi tmp]$ sudo ufw enable</code></pre> </section> <section id="ssh-kulcsok" class="slide level1"> <h1>SSH kulcsok</h1> <ul> <li>biztonságosabb, mint egy jelszó</li> <li>sok algoritmus, RSA, elliptikus görbék</li> <li>publikus-privát</li> <li>privát saját gépen, védve</li> <li>publikus ott, ahova belépnénk</li> <li><code>~/.ssh/authorized_keys</code></li> </ul> </section> <section id="generálás" class="slide level1"> <h1>Generálás</h1> <pre class="shell-session"><code>mike@thinkyboi:~$ ssh-keygen Generating public/private rsa key pair. Enter file in which to save the key (/home/mike/.ssh/id_rsa): Created directory '/home/mike/.ssh'. Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/mike/.ssh/id_rsa Your public key has been saved in /home/mike/.ssh/id_rsa.pub The key fingerprint is: SHA256:tYZX08XEZfJP5j/um2Y9KUgG+jffe82ONwgzkt4p0hc mike@thinkyboi The key's randomart image is: +---[RSA 3072]----+ | .+*| | . =o| | . o . +| | + o . +.| | S * o| | . = E .| | + = B .o=| | . = B ooBO| | . + o.*XB| +----[SHA256]-----+ mike@thinkyboi:~$ cat .ssh/id_rsa.pub ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDjAZMAbpNutuc/ZgHWMcjWcPQOC0d8+JrDaHMnxZfRtfdyrgZDfPmMER95148JVEfkjjhur8a+IEfQM59o+yq95+yNvJFT6Nr5JzHK8dC5IuDvvEVNrKPwmW4UIgm1e5b95pGivJ5cnoiXevtp87seaxh0DlZFONKUeIFnwyDBUII7mRyXDn7MrFlAcxXtlZnSSCXXLGUMZI7nldiyRI9gXlZYCpfA8XrXrnM6JAIA+6VozhJurAKhygV6rH5yD4Vg+/Bs+wigywE3U79gbqpPzRegmxzKdgv+NNKV900DQVYNzvCU5o6q9d2amU+CDSw6KjU+4SLFOgZ3myXCyE9er3aaROj22sQdPwv8CnwtZstRibpp2SU627J4Vr7caPl8wrZcGvmXgD50mPh9Kdd+Yr5WJFSaAcog082aWBdrB3Qr9LM5DgcWulyDmUMmjA2WWCJN+t6vDT5d+2mYeBiZ2OY5ZkHyUjD6GVGBOZP/lP9EAxi3XwoM3V8TwoEgLD8= mike@thinkyboi mike@thinkyboi:~$ </code></pre> </section> <section id="operátor" class="slide level1"> <h1><code>>></code> operátor</h1> <ul> <li><code>></code> tesója</li> <li>filehoz appendál</li> </ul> <pre class="shell"><code>curl https://git.sch.bme.hu/mikewashere.keys >> ~/.ssh/authorized_keys</code></pre> </section> <section id="házi-feladatok" class="slide level1"> <h1>Házi Feladatok</h1> </section> <section id="alap-házi" class="slide level1"> <h1>Alap házi</h1> <p>Csinálj felhasználót a csapattársaidnak a VM-edre úgy, hogy hozzáférjenek a statikus weboldalak mappájához, ezután próbáljátok ki, hogy valóban hozzáfértek-e és ha igen, rakjatok valami funky html-t a mappánba ajándékba a társaitoknak.</p> <p>Hint: adduser/useradd, usermod/gpasswd, chmod.</p> </section> <section id="side-quest" class="slide level1"> <h1>Side Quest</h1> <p>Állíts be kulcsos hitelesítést a képzés VM-eden az SSH kapcsolatodhoz. Ehhez szükséged lesz egy privát és egy publikus kulcsra a kliensgépeden.</p> <p>Hint: ssh-keygen.</p> </section> <section id="expert-sudo" class="slide level1"> <h1>Expert (sudo)</h1> <p>Nyomozz hogyan és miért műküdik a sudo parancs! Ha megtaláltad próbáld meg összefoglalni nekünk néhány mondatban.</p> <p>Hint: setuid</p> </section> <section id="expert-csomag-mágus" class="slide level1"> <h1>Expert (Csomag mágus)</h1> <p>Készíts egy új csomagot (package) egy általad válaszott programból (saját program is lehet), egy általad választott disztribúcióhoz.</p> </section> <section id="jó-munkát" class="slide level1"> <h1>Jó munkát</h1> </section> </div> </div> <script src="https://unpkg.com/reveal.js@^4//dist/reveal.js"></script> // reveal.js plugins <script src="https://unpkg.com/reveal.js@^4//plugin/notes/notes.js"></script> <script src="https://unpkg.com/reveal.js@^4//plugin/search/search.js"></script> <script src="https://unpkg.com/reveal.js@^4//plugin/zoom/zoom.js"></script> <script> // Full list of configuration options available at: // https://revealjs.com/config/ Reveal.initialize({ // Push each slide change to the browser history history: true, // reveal.js plugins plugins: [ RevealNotes, RevealSearch, RevealZoom ] }); </script> </body> </html>