====== Systemaktualisierungen (Updates) unter Linux mit APT ====== Um das Betriebssystem eines Rechners stets aktuell zu halten, empfehlen wir regelmäßige Systemaktualisierungen. Systemaktualisierungen können manuell vorgenommen werden, oder automatisiert im Hintergrund angestoßen werden. Dieser Beitrag behandelt Systemaktualisierungen durch das "Advanced Packaging Tool", kurz: [[uu>APT]]. APT ist ein Paketmanagement-System, welches im Bereich des Betriebssystems [[gnu_linux:debian_gnu_linux|Debian]] GNU/Linux entstanden ist. ===== manuelle Systemaktualisierungen ===== Um zu prüfen zu welchen Paketquellen neue Versionen verfügbar sind, werden zunächst die Paketlisten aus den Paketquellen aktualisiert: sudo apt update Verfügbare Systemaktualisierungen können dann installiert werden: sudo apt dist-upgrade Das war's! ===== automatische Systemaktualisierungen ===== Um Systemaktualisierungen automatisch (im nachfolgenden Beispiel: täglich) durchzuführen, werden die einzelnen Schritte in einem Shellskript zusammengefasst und via (Ana)Cron automatisiert aufgerufen: sudo cat < /etc/cron.daily/distupgrade && chmod +x /etc/cron.daily/distupgrade #! /usr/bin/env bash apt-get update && apt-get --yes dist-upgrade EOF Ein ausführliches Skript inklusive Protokollierung kann z.B. so aussehen: sudo -s cat <<-"EOF" > /etc/cron.daily/distupgrade && chmod +x /etc/cron.daily/distupgrade #! /usr/bin/env bash # ---------------------------------- METADATA ---------------------------------- script_name="distupgrade" script_version="1.1.8" script_author="Till Neuhaus (Neuhaus-IT.de)" script_description="This script is used for upgrading debian-based distributions. The behavior of this script can differ between distributions." script_license_short="AGPL3+" script_license_long="GNU Affero General Public License (https://www.gnu.org/licenses/agpl.html) version 3 or later" clear # Check if the script is run with administrative privileges and exit if not if [[ $EUID -ne 0 ]] then echo "This script must be executed with administrative privileges. Please try \"sudo ${0}\" for example." exit 1 fi # Set Variables logfile="/var/log/distupgrade.log" timestamp=$(date +%Y-%m-%d-%H:%M) # Create backup of existing logfile (if existing) if [[ -f "$logfile" ]] then cp "$logfile" "${logfile}.bak" fi echo "This script was executed ${timestamp}" | tee "$logfile" echo | tee --append "$logfile" # Retrieve new lists of packages echo "Retrieving new lists of packages..." | tee --append "$logfile" apt-get update >> "$logfile" | tee --append "$logfile" echo "Done!" | tee --append "$logfile" echo | tee --append "$logfile" # Distribution upgrade echo "Upgrading the distribution..." | tee --append "$logfile" apt-get dist-upgrade --yes >> "$logfile" | tee --append "$logfile" echo "Done!" echo | tee --append "$logfile" # Remove automatically all unused packages and purging their configurations echo "Removing unused packages..." | tee --append "$logfile" apt-get --purge --yes autoremove >> "$logfile" | tee --append "$logfile" echo "Done!" | tee --append "$logfile" echo | tee --append "$logfile" echo "Script done! See the logfile under \"${logfile}\"." EOF exit Auf Wunsch kann man sich die Protokolle z.B. via [[gnu_linux:anwendungen:sendxmpp|Sendxmpp]] zusenden lassen. ===== Links & Quellen ===== * [[https://wiki.ubuntuusers.de/Aktualisierungen/Konfiguration/#Automatische-Updates-ohne-Interaktion|Ubuntusers zu automatischen Systemaktualisierungen unter Linux"]] * [[debianwiki>StableUpdates|Debian-Wiki zu "Systemaktualisierungen"]] * [[suche>Linux Systemaktualisierungen OR Updates|Websuche nach "Linux Systemaktualisierungen OR Updates"]] ---- **Workflow (Tags):**\\ Beitrag_Entwurf, Beitrag_veröffentlicht {{tag>Beitrag_Entwurf entwuerfe Linux Update Upgrade}}