This commit is contained in:
Daniel Schubert 2019-01-20 21:49:50 +01:00
parent c17a7e3b42
commit 91eb1a3de4
2 changed files with 273 additions and 114 deletions

286
8.html
View File

@ -120,6 +120,7 @@
<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>
</section>
<section data-transition="slide" data-background="#4d7e65" data-background-transition="convex">
<h2>Part 5 - systemd</h2>
@ -139,6 +140,12 @@
</section>
<section>
<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>
<p>systemd ist organisiert mit
<ul>
@ -161,100 +168,14 @@
<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>
</ul>
</section>
<section>
<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>
<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>
<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>
</ul>
</section>
<section>
<h3>Eine unit</h3>
<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>
<span style="color: orange">Aufgabe:</span> Erstellt eine Unit und startet sie.
<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>
<li class="fragment ">UnDo: <pre><code>systemctl revert unit</code></pre></li>
</ul>
</section>
<section>
<h4>Ensprechenungen der alten Runlevel und der neuen Targets</h4>
<table class="wikitable" style="font-size:.4em">
@ -301,44 +222,181 @@ python3 -m http.server 8082 </code></pre>
</tbody></table>
</section>
<section>
Ausserdem:
<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>
</section>
<section>
<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>
<li class="fragment ">Dienst Autostart abschalten<pre><code>systemctl disable DIENST</code></pre></li>
</ul>
</section>
<section>
<h3>Eine unit</h3>
<code style="font-size: .4em">/lib/systemd/system/ssh.service</code>
<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>
<span style="color: orange">Aufgabe:</span> Erstellt eine Unit und startet sie.<p>
https://wiki.archlinux.org/index.php/Systemd#Writing_unit_files
<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>
<ul>
<li class="fragment ">mount -> systemd kann Dateisysteme mounten</li>
<li class="fragment ">timer -> systemd kann cron ersetzen</li>
</ul>
</section>
<section>
<h4>journalctl</h4>
Das logging system moderner Linux Distributionen.
</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>
<h4>systemctl</h4>
</section>
<section>Browser öffnen: <code>http://localhost:8082/BENUTZERNAME</code></section>
<section><h4>Ändern der Standard-Units</h4>
<section data-transition="slide" data-background="#4d7e65" data-background-transition="convex">
<h2>Part 5 - daemons</h2>
<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>
<li class="fragment "> Aktualiseren <code>systemctl daemon-reload </code></li>
<li class="fragment ">UnDo: <pre><code>systemctl revert unit</code></pre></li>
</ul>
</section>
<section>
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>
</section>
<section>
https://wiki.archlinux.org/index.php/Systemd/Timers
<aside class="notes">üben doku lesen</aside>
</section>
<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 data-transition="slide" data-background="#4d7e65" data-background-transition="convex">
<h2>Part 6 - Uhrzeit und Datum</h2>
</section>
<section data-transition="slide" data-background="#4d7e65" data-background-transition="convex">
<h2>Part 7 - Startup / Shutdown</h2>
<section>
<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>
<code style="font-size: .5em">/etc/systemd/system/backup.service</code>
<pre><code>
[Unit]
Description=Backup 2000
[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>
<section>
<h4>journalctl</h4>
<pre><code>journalctl</code></pre>
<pre><code>journalctl -xe</code></pre>
<pre><code>journalctl --unit=backup.service </code></pre>
<aside class="notes">man journalctl</aside>
</section>
<section>
timedatectl
<p>https://wiki.ubuntuusers.de/Systemzeit/
<p>https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/system_administrators_guide/sect-managing_services_with_systemd-targets
</section>
<section data-transition="slide" data-background="#4d7e65" data-background-transition="convex">
<h2>Part 7 - Startup / Shutdown</h2>
</section>
</div>
</div>

101
9.html Normal file
View File

@ -0,0 +1,101 @@
<!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>
<style type="text/css">
.reveal img{ max-height: 60vh}
</style>
</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>
<p>Eine Einführung - Teil 9
<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">
<h2 style="text-shadow: 5px 4px 15px black;">Systemverwaltung</h2>
</section>
<section>
Dateisysteme mounten
</section>
<section>Netzwerke</section>
<section>IP Adressen</section>
<section>SSH</section>
</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>