Skip to content
Snippets Groups Projects
Commit de14cf2e authored by Nikolai Milenko's avatar Nikolai Milenko :grinning:
Browse files

Upload New File

parent 7bacb588
No related branches found
No related tags found
No related merge requests found
# 📖 Lerntagebuch - Woche 12
---
### **Thema: Paketmanagement mit apt und apt-get**
#### **Vorbereitungen**
- **Hilfefunktion genutzt**: `apt --help`
- Interessante Befehle:
- `apt list --upgradable` → zeigt alle aktualisierbaren Pakete an.
- `apt show <paketname>` → zeigt detaillierte Informationen zu einem Paket.
#### **Systemaktualisierung**
```bash
┌─[user@parrot]─[~]
└──╼ $sudo apt update
Get:1 https://deb.parrot.sh/parrot lory InRelease [29.8 kB]
Get:2 https://deb.parrot.sh/direct/parrot lory-security InRelease [29.4 kB]
Get:3 https://deb.parrot.sh/parrot lory-backports InRelease [29.7 kB]
Get:4 https://deb.parrot.sh/parrot lory/main amd64 Packages [19.2 MB]
Get:5 https://deb.parrot.sh/direct/parrot lory-security/main amd64 Packages [476 kB]
Get:6 https://deb.parrot.sh/parrot lory-backports/main amd64 Packages [658 kB]
Get:7 https://deb.parrot.sh/parrot lory-backports/contrib amd64 Packages [10.9 kB]
Fetched 20.4 MB in 6s (3596 kB/s)
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
20 packages can be upgraded. Run 'apt list --upgradable' to see them.
```
Also, 20 Paketen können aktualisiert werden.
```bash
sudo apt upgrade
...
The following packages will be upgraded:
bind9-dnsutils bind9-host bind9-libs buildah dnsutils firefox-esr golang-go golang-src iproute2 libdw1 libelf1 libtasn1-6 openjdk-17-jdk openjdk-17-jdk-headless openjdk-17-jre
openjdk-17-jre-headless vim-common vim-tiny xxd yt-dlp
20 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
...
```
#### **Paketinstallation und -entfernung**
- **Suche nach einem Paket mit „transfer“**
```bash
apt search transfer
...
curl/parrot6-backports,now 8.11.1-1~bpo12+1 amd64 [installed,automatic]
command line tool for transferring data with URL syntax
...
```
- **Installation von `curl`**
```bash
┌─[user@parrot]─[~]
└──╼ $sudo apt install curl
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
curl is already the newest version (8.11.1-1~bpo12+1).
curl set to manually installed.
```
Also Paket curl war schon installiert.
- **Entfernen von `tree`**
```bash
┌─[user@parrot]─[~]
└──╼ $sudo apt remove tree
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:
golang-1.22-go golang-1.22-src
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
tree
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
After this operation, 116 kB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 353458 files and directories currently installed.)
Removing tree (2.1.0-1) ...
Processing triggers for man-db (2.11.2-2) ...
Scanning application launchers
Removing duplicate launchers or broken launchers
Launchers are updated
```
Überprüfung der Entfernung:
```bash
┌─[user@parrot]─[~]
└──╼ $apt-cache policy tree
tree:
Installed: (none)
Candidate: 2.1.0-1
Version table:
2.1.0-1 600
600 https://deb.parrot.sh/parrot lory/main amd64 Packages
```
- **Neuinstallation von `tree`**
```bash
┌─[user@parrot]─[~]
└──╼ $sudo apt install tree
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:
golang-1.22-go golang-1.22-src
Use 'sudo apt autoremove' to remove them.
The following NEW packages will be installed:
tree
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
```
- **System von nicht mehr benötigten Abhängigkeiten bereinigen**
```bash
# Liste der entfernten Pakete:
┌─[user@parrot]─[~]
└──╼ $sudo apt autoremove
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages will be REMOVED:
golang-1.22-go golang-1.22-src
0 upgraded, 0 newly installed, 2 to remove and 0 not upgraded.
After this operation, 228 MB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 353458 files and directories currently installed.)
Removing golang-1.22-go (1.22.11-1~bpo12+1) ...
Removing golang-1.22-src (1.22.11-1~bpo12+1) ...
Scanning application launchers
Removing duplicate launchers or broken launchers
Launchers are updated
```
#### **Abhängigkeitsverwaltung**
- **Untersuchung der Abhängigkeiten von `curl`**
```bash
┌─[user@parrot]─[~]
└──╼ $apt-cache depends curl
curl
Depends: libc6
Depends: libcurl3-gnutls
Depends: zlib1g
```
---------------------------
In der Ausgabe des Befehls `apt-cache depends curl` sehen wir die zwingenden Abhängigkeiten (Depends) für das Paket curl.
#### Zwingende Abhängigkeiten (Depends)
Diese Pakete müssen installiert sein, damit curl funktioniert:
- libc6 – Die Standard-C-Bibliothek für Linux
- libcurl3-gnutls – Die Bibliothek, die curl die Fähigkeit gibt, Netzwerkverbindungen über verschiedene Protokolle (HTTP, FTP, etc.) herzustellen.
- zlib1g – Eine Bibliothek zur Datenkompression
#### Optionale Abhängigkeiten (Recommends oder Suggests)
Diese werden nicht automatisch benötigt, können aber nützlich sein:
- Recommends: Automatisch mitinstalliert, aber entfernbar.
- Suggests: Werden empfohlen, sind aber nicht zwingend.
----
- **Defekte Abhängigkeiten reparieren**
```bash
# Simuliert die Reparatur
┌─[user@parrot]─[~]
└──╼ $sudo apt-get -s install -f
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
```
#### **Erweiterte Paketverwaltung**
- **Verfügbare Versionen von `curl` anzeigen**
```bash
┌─[user@parrot]─[~]
└──╼ $apt-cache policy curl
curl:
Installed: 8.11.1-1~bpo12+1
Candidate: 8.11.1-1~bpo12+1
Version table:
*** 8.11.1-1~bpo12+1 599
599 https://deb.parrot.sh/parrot lory-backports/main amd64 Packages
100 /var/lib/dpkg/status
7.88.1-10+deb12u9 600
600 https://deb.parrot.sh/parrot lory/main amd64 Packages
7.88.1-10+deb12u5 600
600 https://deb.parrot.sh/direct/parrot lory-security/main amd64 Packages
```
- **Spezifische Version installieren**
```bash
┌─[✗]─[user@parrot]─[~]
└──╼ $sudo apt-get install curl=7.88.1-10+deb12u5
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
curl : Depends: libcurl4 (= 7.88.1-10+deb12u5) but 8.11.1-1~bpo12+1 is to be installed
E: Unable to correct problems, you have held broken packages.
```
Also es erscheint nur möglich, die letzte Version zu installieren.
- **`curl` für automatische Updates sperren**
```bash
┌─[✗]─[user@parrot]─[~]
└──╼ $sudo apt-mark hold curl
curl set on hold.
# Überprüfung der Sperrung
┌─[user@parrot]─[~]
└──╼ $apt-mark showhold
curl
```
- **Sperrung aufheben**
```bash
┌─[user@parrot]─[~]
└──╼ $sudo apt-mark unhold curl
Canceled hold on curl.
```
#### **Wichtige Befehle und ihre Bedeutung**
| Befehl | Bedeutung |
|-----------------------------|-----------|
| `sudo apt update` | Aktualisiert die Paketlisten |
| `sudo apt upgrade` | Aktualisiert alle installierten Pakete |
| `sudo apt install <paket>` | Installiert ein Paket |
| `sudo apt remove <paket>` | Entfernt ein Paket |
| `apt-cache depends <paket>` | Zeigt Abhängigkeiten eines Pakets |
| `sudo apt-mark hold <paket>` | Verhindert automatische Updates für ein Paket |
| `sudo apt autoremove` | Entfernt ungenutzte Abhängigkeiten |
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment