2019-01-17 10:00:51 +01:00
<!doctype html>
< html lang = "de" >
< meta charset = "utf-8" >
< title > Einführung in Linux< / title >
< meta name = "description" content = "YALC - Yet Another Linux Course " >
< meta name = "author" content = "Daniel Schubert" >
< 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" >
< link rel = "stylesheet" href = "css/reveal.css" >
< link rel = "stylesheet" href = "css/theme/league.css" id = "theme" >
< link rel = "icon" href = "img/openlogo-nd-25.png" type = "img/png" >
<!-- Theme used for syntax highlighting of code -->
< link rel = "stylesheet" href = "lib/css/zenburn.css" >
<!-- Printing and PDF exports -->
< script >
var link = document.createElement( 'link' );
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = window.location.search.match( /print-pdf/gi ) ? 'css/print/pdf.css' : 'css/print/paper.css';
document.getElementsByTagName( 'head' )[0].appendChild( link );
< / script >
2019-01-20 20:53:32 +01:00
< style type = "text/css" >
.reveal img{ max-height: 60vh}
< / style >
2019-01-17 10:00:51 +01:00
< / head >
< body >
< div class = "reveal" >
<!-- Any section element inside of this container is displayed as a slide -->
< div class = "slides" >
< section data-transition = "slide" data-background = "#4d7e65" data-background-transition = "zoom" >
< h1 > LINUX< / h1 >
< h3 > Das universelle Betriebssystem< / h3 >
2019-01-20 20:53:32 +01:00
< p > Eine Einführung - Teil 8
2019-01-17 10:00:51 +01:00
< p >
< small > Deutsche Angestellten Akademie< / small >
< / p >
< aside class = "notes" >
Frage: Fragen zur letzten Stunde?
< / aside >
< / section >
< section data-transition = "slide" data-background = "lightblue" data-background-transition = "zoom" >
2019-01-20 20:53:32 +01:00
< h2 style = "text-shadow: 5px 4px 15px black;" > Systemverwaltung< / h2 >
< / section >
< section >
Begriff: daemon
< p > Ein Systemdienst der automatisch startet und ohne Eingriffe arbeitet ( meistens :-) )
< p > vgl. Dienste unter Windows
< p > Name endet oft mit „d“
< ul >
< li > systemd - ...
< li > sshd - SSH Server Daemon
< li > dockerd - docker daemon
< li > smbd - SAMBA File Server
< li > ntpd - Network Time Protocal Daemon
< li > atd - at Daemon
< / section >
< section style = "" >
< p > Begriff: Runlevel< / p >
< table class = "prettytable" style = " font-size: .4em; border:solid 2px #677089;" >
< tbody > < tr style = "" >
< th style = "line-height:2.5em;" > Runlevel< / th >
< th > Beschreibung
< / th > < / tr >
< tr style = "border-bottom:solid 2px #AAAAAA;" >
< td style = "text-align:center;font-weight:bold;" > 0
< / td >
< td style = "padding:4px 8px;line-height:118%;" > Shutdown. Alle Netzverbindungen werden geschlossen, Dateipuffer werden geschrieben, Mounts auf Partitionen werden entfernt (d. h. die im Verzeichnisbaum eingebundenen Datenträger werden ausgehängt).
< / td > < / tr >
< tr style = "border-bottom:solid 2px #AAAAAA;" >
< td style = "text-align:center;font-weight:bold;" > S
< / td >
< td style = "padding:4px 8px;line-height:118%;" > Single-User-Runlevel; niedrigster Systemzustand für Wartungsarbeiten, in dem ausschließlich Systemressourcen wie < a href = "/wiki/Festplatten" class = "mw-redirect" title = "Festplatten" > Festplatten< / a > oder < a href = "/wiki/Dateisystem" title = "Dateisystem" > Dateisysteme< / a > aktiv sind.
< / td > < / tr >
< tr style = "border-bottom:solid 2px #AAAAAA;" >
< td style = "text-align:center;font-weight:bold;" > 1
< / td >
< td style = "padding:4px 8px;line-height:118%;" > Einzelnutzerbetrieb ohne Netzwerk mit ausschließlich lokalen Ressourcen. In vielen Implementierungen identisch mit 'S'.
< / td > < / tr >
< tr style = "border-bottom:solid 2px #AAAAAA;" >
< td style = "text-align:center;font-weight:bold;" > 2
< / td >
< td style = "padding:4px 8px;line-height:118%;" > Lokaler Mehrnutzerbetrieb ohne Netzwerk mit ausschließlich lokalen Ressourcen. Unter einigen Linuxdistributionen (z. B. Debian) wird in Runlevel 2 auch das Netzwerk konfiguriert.
< / td > < / tr >
< tr style = "border-bottom:solid 2px #AAAAAA;" >
< td style = "text-align:center;font-weight:bold;" > 3
< / td >
< td style = "padding:4px 8px;line-height:118%;" > Netzwerkbetrieb, über das Netzwerk erreichbare Ressourcen sind nutzbar, eine grafische Oberfläche steht nicht zur Verfügung. Firewalls sollten aktiviert werden.
< / td > < / tr >
< tr style = "border-bottom:solid 2px #AAAAAA;" >
< td style = "text-align:center;font-weight:bold;" > 4
< / td >
< td style = "padding:4px 8px;line-height:118%;" > Ist normalerweise nicht definiert. Kann aber für diverse Dienste genutzt werden.
< / td > < / tr >
< tr style = "border-bottom:solid 2px #AAAAAA;" >
< td style = "text-align:center;font-weight:bold;" > 5
< / td >
< td style = "padding:4px 8px;line-height:118%;" > Wie 3, zusätzlich wird die grafische Oberfläche bereitgestellt.
< / td > < / tr >
< tr >
< td style = "text-align:center;font-weight:bold;" > 6
< / td >
< td style = "padding:4px 8px;line-height:118%;" > Reboot. Alle Netzverbindungen werden geschlossen, Dateipuffer werden geschrieben, Mounts auf Partitionen werden entfernt.
< / td > < / tr > < / tbody > < / table >
2019-01-17 10:00:51 +01:00
< / section >
2019-01-20 21:49:50 +01:00
2019-01-20 20:53:32 +01:00
2019-01-17 10:00:51 +01:00
< section data-transition = "slide" data-background = "#4d7e65" data-background-transition = "convex" >
2019-01-20 20:53:32 +01:00
< h2 > Part 5 - systemd< / h2 >
2019-01-17 10:00:51 +01:00
< / section >
2019-01-20 20:53:32 +01:00
< section >
< ul >
< li class = "" > Relativ neu
< li class = "fragment" > bricht mit alter Linux Philosophie:< br > -- do one thing and do it well --
< li class = "fragment" > Sysvinit funktioniert über Shell Scripte, die nacheinander abgearbeitet werden
< li class = "fragment" > Systemd ist schneller - startet Dienste parallel
< li class = "fragment" > Kritik : übernimmt sehr viel Kontrolle - single point of failure
< li class = "fragment" > zB Gnome3 ist abhängig von systemd
< li class = "fragment" > -->Abspaltungen: Devuan - nutzt weiterhin Sysvinit
< li class = "fragment" > Standard in : Debian RedHat Suse Ubuntu
< / section >
< section >
2019-01-20 21:49:50 +01:00
< h4 > Der Boot-Ablauf mit systemd< / h4 >
< img style = "max-height: 50vh" src = "img/startup-systemd.png" >
< p > < small > Das initramfs ist ein komprimiertes Archiv, das für den Systemstart benötigte Dateien enthält.< / small >
< / section >
< section >
2019-01-17 10:00:51 +01:00
2019-01-20 20:53:32 +01:00
< p > systemd ist organisiert mit
< ul >
< li class = "fragment" > units - einzelne Dienste
< li class = "fragment" > targets - Gruppen von Diensten, Systemzustände
< ul > < li > entspr. runlevel unter Sysvinit< / li > < / ul >
< / ul >
< p >
< div class = "fragment" >
Dateien:
< p > /lib/systemd/system/ -> default
< p > /etc/systemd/system/ -> custom
< / div >
< / section >
< section >
< h3 > Informationen anzeigen< / h3 >
< ul >
< li class = "fragment " > Systemstatus anzeigen:< pre > < code > systemctl status< / code > < / pre > < / li >
< li class = "fragment " > Liste der fehlgeschlagenene Units < pre > < code > systemctl --failed< / code > < / pre > < / li >
< li class = "fragment " > Liste aller installierter Units< pre > < code > systemctl list-unit-files< / code > < / pre > < / li >
2019-01-17 10:00:51 +01:00
< / section >
2019-01-20 21:49:50 +01:00
< section >
< div > Default Target< pre > < code > systemctl get-default< / code > < / pre > < / div >
< div class = "fragment " > Alle Targets< pre > < code > systemctl list-units --type target< / code > < / pre > < / div >
< / section >
< section >
< h4 > Ensprechenungen der alten Runlevel und der neuen Targets< / h4 >
< table class = "wikitable" style = "font-size:.4em" >
< tbody > < tr >
< th > SysV Runlevel< / th >
< th > systemd Target< / th >
< th > Notes
< / th > < / tr >
< tr >
< td > 0< / td >
< td > runlevel0.target, poweroff.target< / td >
< td > Halt the system.
< / td > < / tr >
< tr >
< td > 1, s, single< / td >
< td > runlevel1.target, rescue.target< / td >
< td > Single user mode.
< / td > < / tr >
< tr >
< td > 2, 4< / td >
< td > runlevel2.target, runlevel4.target, multi-user.target< / td >
< td > User-defined/Site-specific runlevels. By default, identical to 3.
< / td > < / tr >
< tr >
< td > 3< / td >
< td > runlevel3.target, multi-user.target< / td >
< td > Multi-user, non-graphical. Users can usually login via multiple consoles or via the network.
< / td > < / tr >
< tr >
< td > 5< / td >
< td > runlevel5.target, graphical.target< / td >
< td > Multi-user, graphical. Usually has all the services of runlevel 3 plus a graphical login.
< / td > < / tr >
< tr >
< td > 6< / td >
< td > runlevel6.target, reboot.target< / td >
< td > Reboot
< / td > < / tr >
< tr >
< td > emergency< / td >
< td > emergency.target< / td >
< td > Emergency shell
< / td > < / tr >
< / tbody > < / table >
< / section >
2019-01-17 10:00:51 +01:00
2019-01-20 20:53:32 +01:00
< section >
< h3 > Dienste Steuern< / h3 >
< ul >
< li class = "fragment " > Laufende Dienste anzeigen:< pre > < code > systemctl< / code > < / pre > < / li >
< li class = "fragment " > Eine Unit starten < pre > < code > systemctl start DIENST< / code > < / pre > < / li >
< li class = "fragment " > Eine Unit neu starten< pre > < code > systemctl restart DIENST< / code > < / pre > < / li >
< li class = "fragment " > Unit Status anzeigen< pre > < code > systemctl status DIENST< / code > < / pre > < / li >
< / ul >
2019-01-17 10:00:51 +01:00
< / section >
< section >
2019-01-20 20:53:32 +01:00
< ul >
< li class = "fragment " > Dienst Autostart anschalten< pre > < code > systemctl enable DIENST< / code > < / pre > < / li >
< li class = "fragment " > Dienst Autostart anschalten und sofort starten< pre > < code > systemctl enable --now DIENST< / code > < / pre > < / li >
2019-01-20 21:49:50 +01:00
< li class = "fragment " > Dienst Autostart abschalten< pre > < code > systemctl disable DIENST< / code > < / pre > < / li >
2019-01-20 20:53:32 +01:00
< / ul >
2019-01-17 10:00:51 +01:00
< / section >
2019-01-20 20:53:32 +01:00
< section >
< h3 > Eine unit< / h3 >
2019-01-20 21:49:50 +01:00
< code style = "font-size: .4em" > /lib/systemd/system/ssh.service< / code >
2019-01-20 20:53:32 +01:00
< pre style = "font-size: .4em" > < code > [Unit]
Description=OpenBSD Secure Shell server
After=network.target auditd.service
ConditionPathExists=!/etc/ssh/sshd_not_to_be_run
[Service]
EnvironmentFile=-/etc/default/ssh
ExecStartPre=/usr/sbin/sshd -t
ExecStart=/usr/sbin/sshd -D $SSHD_OPTS
ExecReload=/usr/sbin/sshd -t
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=on-failure
RestartPreventExitStatus=255
Type=notify
RuntimeDirectory=sshd
RuntimeDirectoryMode=0755
[Install]
WantedBy=multi-user.target
Alias=sshd.service
< / code > < / pre >
< / section >
< section >
2019-01-20 21:49:50 +01:00
< span style = "color: orange" > Aufgabe:< / span > Erstellt eine Unit und startet sie.< p >
https://wiki.archlinux.org/index.php/Systemd#Writing_unit_files
2019-01-20 20:53:32 +01:00
< div class = "fragment" >
< code style = "font-size: .5em" > /etc/systemd/system/simple-webserver.service< / code >
< pre > < code > [Unit]
Description=Simple Web Server
[Service]
Type=simple
ExecStart=/home/USERNAME-HIER-EINSETZEN/hello-web.sh
[Install]
WantedBy=multi-user.target
< / code > < / pre >
< code style = "font-size: .5em" > ~/hello-web.sh< / code >
< pre > < code > #!/bin/bash
cd /home/
python3 -m http.server 8082 < / code > < / pre >
< / div >
< / section >
< section >
< pre > < code > systemctl start simple-webserver.service< / code > < / pre >
< pre > < code > systemctl status simple-webserver.service< / code > < / pre >
Wenn das gescheitert sein sollte:
< pre > < code > journalctl -xe < / code > < / pre >
< pre > < code > journalctl --unit=simple-webserver.service < / code > < / pre >
< / section >
< section > Browser öffnen: < code > http://localhost:8082/BENUTZERNAME< / code > < / section >
< section > < h4 > Ändern der Standard-Units< / h4 >
< ul >
< li class = "fragment " > < pre > < code > systemctl edit unit< / code > < / pre > < / li >
< li class = "fragment " > Öffnet < code > /etc/systemd/system/unit.d/override.conf< / code > < / li >
2019-01-20 21:49:50 +01:00
< li class = "fragment " > Aktualiseren < code > systemctl daemon-reload < / code > < / li >
2019-01-20 20:53:32 +01:00
< li class = "fragment " > UnDo: < pre > < code > systemctl revert unit< / code > < / pre > < / li >
< / ul >
< / section >
2019-01-20 21:49:50 +01:00
2019-01-20 20:53:32 +01:00
< section >
2019-01-20 21:49:50 +01:00
timer als cron Ersatz
< pre > < code > systemctl list-timers --all< / code > < / pre >
< div class = "fragment" > die Timer Datei muss den selben namen haben wie das Unit-File< p > < code > toller-dienst.service< / code > < p > < code > toller-dienst.timer< / code > < / div >
< aside class = "notes" >
timer datei ansehen
< / aside >
2019-01-20 20:53:32 +01:00
< / section >
< section >
2019-01-20 21:49:50 +01:00
https://wiki.archlinux.org/index.php/Systemd/Timers
< aside class = "notes" > üben doku lesen< / aside >
2019-01-20 20:53:32 +01:00
< / section >
2019-01-20 21:49:50 +01:00
2019-01-20 20:53:32 +01:00
2019-01-20 21:49:50 +01:00
< section >
< span style = "color: orange" > Aufgabe:< / span > Erstellt einen Backup Service, der per systemd Timer einmal wöchentlich läuft.
< div class = "fragment" >
< code style = "font-size: .5em" > /etc/systemd/system/backup.timer< / code >
< pre > < code >
[Unit]
Description=Run backup.sh weekly
[Timer]
OnCalendar=weekly
Persistent=true
[Install]
WantedBy=timers.target
< / code > < / pre >
< / div >
< / section >
< section >
< code style = "font-size: .5em" > /etc/systemd/system/backup.service< / code >
< pre > < code >
[Unit]
Description=Backup 2000
2019-01-20 20:53:32 +01:00
2019-01-20 21:49:50 +01:00
[Service]
Type=simple
ExecStart=/home/USERNAME-HIER-EINSETZEN/bin/backup.sh
[Install]
WantedBy=multi-user.target
< / code > < / pre >
< / section >
< section >
< code style = "font-size: .5em" > ~/bin/backup.sh< / code >
< pre style = "font-size: .4em" > < code > #!/bin/bash
tar -czf "/home/USERNAME/archiv/backup-`date +%d-%m-%Y`.tar.gz" /home/USERNAME/arbeit/
< / code > < / pre >
< / section >
2019-01-20 20:53:32 +01:00
< section >
< h4 > journalctl< / h4 >
2019-01-20 21:49:50 +01:00
< pre > < code > journalctl< / code > < / pre >
< pre > < code > journalctl -xe< / code > < / pre >
< pre > < code > journalctl --unit=backup.service < / code > < / pre >
2019-01-20 20:53:32 +01:00
2019-01-20 21:49:50 +01:00
< aside class = "notes" > man journalctl< / aside >
2019-01-20 20:53:32 +01:00
< / section >
2019-01-17 10:00:51 +01:00
2019-01-20 21:49:50 +01:00
< section >
timedatectl
< p > https://wiki.ubuntuusers.de/Systemzeit/
2019-01-17 10:00:51 +01:00
2019-01-20 21:49:50 +01:00
< p > https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/system_administrators_guide/sect-managing_services_with_systemd-targets
< / section >
2019-01-17 10:00:51 +01:00
2019-01-20 21:49:50 +01:00
2019-01-20 20:53:32 +01:00
< section data-transition = "slide" data-background = "#4d7e65" data-background-transition = "convex" >
< h2 > Part 7 - Startup / Shutdown< / h2 >
< / section >
2019-01-17 10:00:51 +01:00
2019-01-20 21:49:50 +01:00
2019-01-17 10:00:51 +01:00
< / div >
< / div >
< script src = "lib/js/head.min.js" > < / script >
< script src = "js/reveal.js" > < / script >
< script >
// More info https://github.com/hakimel/reveal.js#configuration
Reveal.initialize({
controls: true,
progress: true,
history: true,
center: true,
transition: 'slide', // none/fade/slide/convex/concave/zoom
// More info https://github.com/hakimel/reveal.js#dependencies
dependencies: [
{ src: 'lib/js/classList.js', condition: function() { return !document.body.classList; } },
{ src: 'plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } },
{ src: 'plugin/search/search.js', async: true },
{ src: 'plugin/zoom-js/zoom.js', async: true },
{ src: 'plugin/notes/notes.js', async: true }
]
});
< / script >
< / body >
< / html >