Skip to content

Commit b11c125

Browse files
author
marci
committed
Aktualisiere das Bash-Script für automatische Debian-Updates und füge umfassende Anweisungen hinzu; passe die YAML-Konfiguration für die Syntaxhervorhebung an.
1 parent 14162d3 commit b11c125

2 files changed

Lines changed: 121 additions & 17 deletions

File tree

content/posts/linux/automatische-update-debian-bash-script.de.md

Lines changed: 101 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@ title: Automatische Updates von Debian mit einem Bash-Script
33
description: Automatisierte Updates auf einem debian-basierenden OS mit einem Bash-Script
44
date: 2025-08-15T08:57:42.002Z
55
tags:
6-
- bash
7-
- linux
8-
- debian
6+
- bash
7+
- linux
8+
- debian
99
categories:
10-
- Linux
11-
- Tutorials
10+
- Linux
11+
- Tutorials
1212
menu:
13-
sidebar:
14-
name: Bash-Script für automatische Updates unter Debian
15-
identifier: debian-update
16-
parent: linux
13+
sidebar:
14+
name: Bash-Script für automatische Updates unter Debian
15+
identifier: debian-update
16+
parent: linux
1717
keywords:
18-
- debian update script
19-
draft: true
18+
- debian update script
19+
draft: false
2020
---
2121
## Updates auf debian-basierenden Systemen automatisieren mit einem Bash-Script
2222

@@ -34,6 +34,7 @@ Als Beispiel schreibe ich ein Script mit dessen Hilfe, Updates von debian-basier
3434
<!-- FM:Snippet:Start data:{"id":"Warning","fields":[]} -->
3535
{{< alert type="warning" >}}
3636
**Warnung**
37+
3738
Bitte Bash-Scripte immer erst auf **Test-Systeme** vorab Testen und dann auf Produktiv-Systemen ausrollen!!!
3839
{{< /alert >}}
3940
<!-- FM:Snippet:End -->
@@ -106,5 +107,94 @@ Im nun offnen Editor-Fenster der Datei `simple_update_debian_script.sh`, gibt ih
106107

107108

108109

110+
## Fertiges Debian-Update Bash-Script
111+
112+
```bash
113+
#!/bin/bash
114+
115+
# Hinweis:
116+
# Dieses Script ist für Debian-basierte Systeme gedacht.
117+
# Es aktualisiert das System und entfernt nicht mehr benötigte Pakete.
118+
# Es überprüft, ob ein Neustart des Systems erforderlich ist und startet es gegebenenfalls SOFORT neu.
119+
# Es ist wichtig, dass das Script als root ausgeführt wird.
120+
121+
# Anwendung:
122+
# sudo chmod +x simple_update_debian_script.sh
123+
# sudo ./simple_update_debian_script.sh
124+
125+
# Info:
126+
# This script is intended for Debian-based systems.
127+
# It updates the system and removes unused packages.
128+
# It checks if a system restart is required and restarts the system if necessary.
129+
# It is important that the script is run as root.
130+
131+
# Using:
132+
# sudo chmod +x simple_update_debian_script.sh
133+
# sudo ./simple_update_debian_script.sh
134+
135+
136+
137+
# Automatisches Update-Script für Debian-basierte Systeme / Automatic update script for Debian-based systems
138+
139+
echo "================================================================="
140+
echo " Automatisches System-Update / Automatic system update"
141+
echo " (Debian/Ubuntu/Mint)"
142+
echo "================================================================="
143+
144+
# Prüfen, ob root-Rechte vorhanden sind / Check if root privileges are present
145+
if [ "$EUID" -ne 0 ]; then
146+
echo "Bitte führen Sie dieses Script als root aus (sudo) / Please run this script as root (sudo)."
147+
exit 1
148+
fi
149+
150+
# Prüfen, ob apt verfügbar ist / Check if apt is available
151+
if ! command -v apt >/dev/null 2>&1; then
152+
echo "Kein 'apt'-Paketmanager gefunden. Dieses Script funktioniert nur auf Debian-basierten Systemen / No 'apt' package manager found. This script only works on Debian-based systems."
153+
exit 2
154+
fi
155+
156+
# Paketquellen aktualisieren / Update package sources
157+
echo "Aktualisiere Paketquellen / Update package sources"
158+
apt update -y
159+
160+
# Upgrades installieren / Install available updates
161+
echo "Installiere verfügbare Updates / Install available updates"
162+
apt upgrade -y
163+
164+
# Optionale Komplett-Aktualisierung (inklusiver Entfernungen/Neuinstallationen) / Optional full upgrade (including removals/reinstallations)
165+
echo "Führe vollständige Aktualisierung durch / Run full upgrade"
166+
apt full-upgrade -y
167+
168+
# Nicht mehr benötigte Pakete entfernen / Remove unused packages
169+
echo "Entferne nicht mehr benötigte Pakete / Remove unused packages"
170+
apt autoremove -y
171+
172+
173+
# Paketdatenbank bereinigen / Clean up cached package data
174+
echo "Bereinige zwischengespeicherte Paketdaten / Clean up cached package data"
175+
apt clean
176+
177+
echo "================================================================="
178+
echo " System-Update abgeschlossen / System update completed"
179+
echo "================================================================="
180+
181+
# Überprüfen ob ein Neustart des Systems erforderlich ist / Check if a system restart is required
182+
if [ -f /var/run/reboot-required ]; then
183+
echo "Ein Neustart des Systems ist erforderlich. Das System wird jetzt neu gestartet / A system restart is required. The system will now restart."
184+
reboot
185+
fi
186+
187+
# Ende des Scripts / End of script
188+
189+
```
190+
191+
<!-- FM:Snippet:Start data:{"id":"Help deutsch","fields":[]} -->
192+
> ## Fragen und Antworten
193+
>
194+
> Wenn Sie Fragen oder Feedback zu diesem Blog oder YouTube-Kanal haben, nutzen Sie bitte meine Hilfeseite. Dort finden Sie Fragen und Antworten zu den verschiedenen Beiträgen. Sie können dort auch gerne Ihre eigene Frage stellen.
195+
>
196+
> [**Zur Hilfeseite**](https://help.secure-bits.org)
197+
<!-- FM:Snippet:End -->
198+
109199

110200

hugo.yaml

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,15 +108,29 @@ markup:
108108
attribute:
109109
block: true
110110

111+
#markup:
112+
# highlight:
113+
# codeFences: true
114+
# style: fruity # dracula # catppuccin-mocha
115+
# lineNos: false
116+
# lineNumbersInTable: false
117+
# wrapperclass: highlight
118+
# guessSyntax: false
111119
markup:
112120
highlight:
121+
anchorLineNos: false
113122
codeFences: true
114-
style: fruity # dracula # catppuccin-mocha
115-
lineNos: true
116-
lineNumbersInTable: false
117-
wrapperclass: highlight
118-
guessSyntax: true
119-
123+
guessSyntax: false
124+
hl_Lines: ""
125+
hl_inline: false
126+
lineAnchors: ""
127+
lineNoStart: 1
128+
lineNos: false
129+
lineNumbersInTable: true
130+
noClasses: true
131+
style: fruity
132+
tabWidth: 4
133+
wrapperClass: highlight
120134

121135
# At least HTML and JSON are required for the main HTML content and
122136
# client-side JavaScript search

0 commit comments

Comments
 (0)