Vorlesung Betriebssysteme I - htw-dresden.derobge/bs1/vl/bs1-02-linux.pdf · I’d like to know...

20
Vorlesung Betriebssysteme I Thema 2: Linux in a Nutshell Robert Baumgartl 18. Oktober 2019 1 / 20

Transcript of Vorlesung Betriebssysteme I - htw-dresden.derobge/bs1/vl/bs1-02-linux.pdf · I’d like to know...

Page 1: Vorlesung Betriebssysteme I - htw-dresden.derobge/bs1/vl/bs1-02-linux.pdf · I’d like to know what features most people would want. Any suggestions are welcome, but I won’t promise

Vorlesung Betriebssysteme IThema 2: Linux in a Nutshell

Robert Baumgartl

18. Oktober 2019

1 / 20

Page 2: Vorlesung Betriebssysteme I - htw-dresden.derobge/bs1/vl/bs1-02-linux.pdf · I’d like to know what features most people would want. Any suggestions are welcome, but I won’t promise

Linux

I bekanntestes Open-Source-Projekt weltweitI Multiuser-Multitasking-BetriebssystemI Unix-artigI Schöpfer: Linus TorvaldsI primär kommandoorientiert, aber auch mit vielen

(schönen) bunten Oberflächen bedienbarI außerordentlich gut skalierbarI für sehr viele Plattformen verfügbar (Auswahl): IA-32,

IA-64, Sun SPARC, Motorola 68000, PowerPC, ARM, IBMS/390, MIPS, HP PA-RISC, Atmel AVR32, AD Blackfin

2 / 20

Page 3: Vorlesung Betriebssysteme I - htw-dresden.derobge/bs1/vl/bs1-02-linux.pdf · I’d like to know what features most people would want. Any suggestions are welcome, but I won’t promise

Im Anfang war ein Posting . . .

From: [email protected] (Linus Benedict Torvalds)Newsgroups: comp.os.minixSubject: What would you like to see most in minix?Summary: small poll for my new operating systemMessage-ID: <[email protected]>Date: 25 Aug 91 20:57:08 GMTOrganization: University of Helsinki

Hello everybody out there using minix -

I’m doing a (free) operating system (just a hobby, won’t be big andprofessional like gnu) for 386(486) AT clones. This has been brewingsince april, and is starting to get ready. I’d like any feedback onthings people like/dislike in minix, as my OS resembles it somewhat(same physical layout of the file-system (due to practical reasons)among other things).

I’ve currently ported bash(1.08) and gcc(1.40), and things seem to work.This implies that I’ll get something practical within a few months, andI’d like to know what features most people would want. Any suggestionsare welcome, but I won’t promise I’ll implement them :-)

Linus ([email protected])

PS. Yes - it’s free of any minix code, and it has a multi-threaded fs.It is NOT protable (uses 386 task switching etc), and it probably neverwill support anything other than AT-harddisks, as that’s all I have :-(.

3 / 20

Page 4: Vorlesung Betriebssysteme I - htw-dresden.derobge/bs1/vl/bs1-02-linux.pdf · I’d like to know what features most people would want. Any suggestions are welcome, but I won’t promise

Evolution

I 17. September 1991: Version 0.01: 241 KiB, 8413 LoC1

I 13. März 1994: Version 1.0.0: 563 KiB, 170.581 LoCI 9. Juni 1996: Version 2.0.0: 2.015 KiB, 716.119 LoCI 9. Oktober 2008: Version 2.6.26.6, mehr als 8 Millionen

LoCI 2017: Version 4.13. ≈ 24.767.008 LoCI neueste Version stets hier: http://kernel.org/

1Lines of Code (Programmzeilen)4 / 20

Page 5: Vorlesung Betriebssysteme I - htw-dresden.derobge/bs1/vl/bs1-02-linux.pdf · I’d like to know what features most people would want. Any suggestions are welcome, but I won’t promise

Kernel vs. System

Mit Linux i. e. S. ist der Kernel, d. h. , das eigentlicheBetriebssystem gemeint.Zu einem Linux-System gehört jedoch viel mehr:I Basiswerkzeuge zur BedienungI Kommandointerpreter (Shell): bash, ksh, csh, tcshI Entwicklungswerkzeuge: gcc (GNU Compiler Collection)I (textbasierte) ApplikationenI grafische Basisschnittstelle: X Window System („X11“)

bzw. neuerdings „Wayland“I FenstermanagerI grafische Applikationen→ Gesamtsystem wird manchmal (korrekter) GNU/Linuxgenannt.

5 / 20

Page 6: Vorlesung Betriebssysteme I - htw-dresden.derobge/bs1/vl/bs1-02-linux.pdf · I’d like to know what features most people would want. Any suggestions are welcome, but I won’t promise

Distributionen

I sind Zusammenstellungen des Kernels, von Applikationenund Werkzeugen zur Konfiguration, die ein lauffähigesGesamtsystem erzeugen

I vereinfachen den Konfigurations- und Updateaufwandbeträchtlich (Paketmanagement)

I unterscheiden sich in vielen Einzelaspekten:I hauptsächliches Einsatzziel Desktoprechner, Server,

eingebettetes SystemI Einstellung zu proprietären KomponentenI Sprachanpassung (Lokalisierung)I . . .

I Frage nach der besten Distribution führt gemeinhin zuMeinungsverschiedenheiten

6 / 20

Page 7: Vorlesung Betriebssysteme I - htw-dresden.derobge/bs1/vl/bs1-02-linux.pdf · I’d like to know what features most people would want. Any suggestions are welcome, but I won’t promise

Beispiele für populäre Distributionen

Name MerkmalGentoo das System wird grundlegend aus den Quellen er-

zeugtFedora freies Linux der Fa. Red HatSUSE weit verbreitet im deutschsprachigen RaumDebian frei, sehr stabil, langer UpdatezyklusUbuntu anfängerfreundlich, vielsprachigKnoppix bekannte Live-DistributionKali sicherheitsorientiert, für PentestingArch Linux „Basis-Betriebssystem für Fortgeschrittene“

Siehe auch:

http://de.wikipedia.org/wiki/Liste_von_Linux-Distributionen

7 / 20

Page 8: Vorlesung Betriebssysteme I - htw-dresden.derobge/bs1/vl/bs1-02-linux.pdf · I’d like to know what features most people would want. Any suggestions are welcome, but I won’t promise

Womit mache ich . . .

Textverarbeitung? libreoffice, LATEXKinoabend? mplayer, vlcInstant Messaging? gajimFotoverwaltung? digikamDiashows? gqview, gwenview

Bildbearbeitung? gimp, rawtherapeeWWW-Recherche? firefox, chromiumNotensatz? lilypondAudioaufnahmen? audacity, rosegardenFunktionsplotting? gnuplotVektorgrafik? inkscape, xfigProgrammeingabe? vi, emacs (nichts anderes!)

8 / 20

Page 9: Vorlesung Betriebssysteme I - htw-dresden.derobge/bs1/vl/bs1-02-linux.pdf · I’d like to know what features most people would want. Any suggestions are welcome, but I won’t promise

Grafische Nutzeroberflächen

I K Desktop Environment (KDE) PlasmaI GNOMEI CinnamonI XfceI UnityI i3

Unterscheidungskriterien:I ’Look & Feel’I TastaturbedienbarkeitI Umfang (Startzeit, Ressourcenbedarf)

Frage nach dem besten Windowmanager→ Chaos.

9 / 20

Page 10: Vorlesung Betriebssysteme I - htw-dresden.derobge/bs1/vl/bs1-02-linux.pdf · I’d like to know what features most people would want. Any suggestions are welcome, but I won’t promise

Erste Hilfe

I man <kommando> zeigt die zugehörige ManualseiteI info <kommando> dito, jedoch mit emacs-SteuerungI apropos <begriff> zeigt zum Suchbegriff gehörige

KommandosI der Schalter --help gibt zu vielen Kommandos nähere

ErklärungenI Das WWW bietet eine Fülle von Hilfen für alle Probleme

rund um Linux

10 / 20

Page 11: Vorlesung Betriebssysteme I - htw-dresden.derobge/bs1/vl/bs1-02-linux.pdf · I’d like to know what features most people would want. Any suggestions are welcome, but I won’t promise

Das Manual

I Manual-Seiten sind in verschiedene Kategorien eingeteilt(man man)I Shellbefehle, z. B. openI Systemrufe, z. B. open()I Bibliotheksfunktionen, z. B. fopen()

I mehrere Sektionen pro Seite: NAME, SYNTAX,BESCHREIBUNG, OPTIONEN, DATEIEN, SIEHE AUCH,FEHLER, und AUTOR

I Humorige Bemerkungen sind häufig, vgl. man 3 gets(unter BUGS) oder man rtfm (sofern installiert)

11 / 20

Page 12: Vorlesung Betriebssysteme I - htw-dresden.derobge/bs1/vl/bs1-02-linux.pdf · I’d like to know what features most people would want. Any suggestions are welcome, but I won’t promise

Die 20 wichtigsten Kommandos – Teil 1

Kdo. Zweckls Verzeichnisanzeige (list)

cd Verzeichniswechsel (change dir)cp Kopieren von Dateien (copy)mv Bewegen von Dateien/Verzeichnissen (move)rm Löschen von Dateien/Verzeichnissen (remove)

mkdir Verzeichnis anlegen (make dir)rmdir Verzeichnis löschen (remove dir)

chmod Rechte einer Datei ändern (change mode)less seitenweise Anzeige von Dateiencat Anzeige des Dateiinhalts (catalogue)

w zeigt an, wer eingeloggt ist (und was er tut)

12 / 20

Page 13: Vorlesung Betriebssysteme I - htw-dresden.derobge/bs1/vl/bs1-02-linux.pdf · I’d like to know what features most people would want. Any suggestions are welcome, but I won’t promise

Die 20 wichtigsten Kommandos – Teil 2

Kdo. Zweckgrep Suche von Zeichenkettenfind Suche nach Dateien

man Anzeige von Manualseitenps Anzeige von Prozessstatistiken (process state)kill Zustellung von Signalenbg Programm in den „Hintergrund“ schicken (background)top Anzeige der rechenintensivsten Prozesse

mount Datenträger einbinden (montieren)du Anzeige des Platzbedarfs von Dateien (disk usage)ln Anlegen eines Verweises (Links)

aber: nicht jedes zweibuchstabige Kürzel ist ein Kommando!13 / 20

Page 14: Vorlesung Betriebssysteme I - htw-dresden.derobge/bs1/vl/bs1-02-linux.pdf · I’d like to know what features most people would want. Any suggestions are welcome, but I won’t promise

Konzept: „Alles ist eine Datei“

3 Kategorien von Dateien:1. „gewöhnliche“ Datei = unstrukturierte Strom von Bytes2. Verzeichnis (Directory) = Datei, die Verzeichniseinträge

enthält3. Spezialdateien:

I Links (Hard Links, symbolische Links)I Geräte (zeichen- oder blockorientiert)I „named pipes“ (FIFOs)I Sockets

Vorteil: einheitliche Behandlung der abstrahierten Objekte.

14 / 20

Page 15: Vorlesung Betriebssysteme I - htw-dresden.derobge/bs1/vl/bs1-02-linux.pdf · I’d like to know what features most people would want. Any suggestions are welcome, but I won’t promise

Die Shell

I normaler Nutzerprozess, der kontinuierlich1. Kommandos einliest,2. diese ausführt,3. etwaige Ausgaben des Programms am Bildschirm darstellt.

I verschiedene: csh, tcsh, ksh, bashI Folgen von Shell-Kommandos nennt man ShellscriptI da die Shell auch Konstrukte für Verzweigungen, Schleifen

und Funktionsaufrufe mitbringt, handelt es sich um eineProgrammiersprache.

I mächtiges Werkzeug

15 / 20

Page 16: Vorlesung Betriebssysteme I - htw-dresden.derobge/bs1/vl/bs1-02-linux.pdf · I’d like to know what features most people would want. Any suggestions are welcome, but I won’t promise

Einfaches Shellscript

#!/bin/bash

# some sanity checksif test ! -x ‘which mac‘ ; then

printf "Please install mac first. Aborting.\n">&2

exit 127fiif test ! -x ‘which lame‘ ; then

printf "Please install lame first. Aborting.\n">&2

exit 127fi

# do the workfor FILE in *.ape ; do

mac "$FILE" "${FILE/ape/wav}" -dlame -h -b320 "${FILE/ape/wav}" "${FILE/ape/mp3}"rm -f "${FILE/ape/wav}"

doneexit 0

16 / 20

Page 17: Vorlesung Betriebssysteme I - htw-dresden.derobge/bs1/vl/bs1-02-linux.pdf · I’d like to know what features most people would want. Any suggestions are welcome, but I won’t promise

Shell vs. Grafikoberfläche - kein Widerspruch

Abbildung: Bla17 / 20

Page 18: Vorlesung Betriebssysteme I - htw-dresden.derobge/bs1/vl/bs1-02-linux.pdf · I’d like to know what features most people would want. Any suggestions are welcome, but I won’t promise

Kurzer Rundgang durchs Dateisystem

. . . machen wir interaktiv.

18 / 20

Page 19: Vorlesung Betriebssysteme I - htw-dresden.derobge/bs1/vl/bs1-02-linux.pdf · I’d like to know what features most people would want. Any suggestions are welcome, but I won’t promise

Was haben wir gelernt?

1. UNIX (in der Gestalt von Linux) ist sehr mächtig und sehrflexibel; es erfordert jedoch eine PortionEinarbeitungsaufwand.

2. Die Shell wird interaktiv bedient.3. Shellscripts sind Kommandofolgen der Shell; die Syntax ist

ein wenig kryptisch, man kann sie aber meistern.4. Das Dateisystem ist ein hierarchischer Baum.

19 / 20

Page 20: Vorlesung Betriebssysteme I - htw-dresden.derobge/bs1/vl/bs1-02-linux.pdf · I’d like to know what features most people would want. Any suggestions are welcome, but I won’t promise

Literaturvorschläge

I Linus Torvalds und David Diamond: Just for Fun. Wie einFreak die Computerwelt revolutionierte, dtv, 2002

I http://www.bin-bash.de/I Stephen Figgis et al: Linux in a Nutshell. 6th ed., O’Reilly,

2009

20 / 20