Debian 13 Tutorial / Verify Security Updates and Configure unattended-upgrades
Apply Debian 13 security updates after checking candidate versions, their repository origins and the proposed package changes. To automate them, configure unattended-upgrades origins, intervals and reboot policy separately. Installing the package or enabling a timer does not prove that fixes were installed: inspect the dry run, actual versions, logs and restart requirements.
Distinguish Security Updates from General Upgrades
First, the repository and signing-key settings must be correct, and the trixie-security list must be retrievable. apt update only refreshes the lists and does not install packages. A general apt upgrade uses the candidates from the configured repositories, so it is not the same as a command that automatically selects and applies only the security sources.
sudo apt update
apt list --upgradable
apt-cache policy zlib1g
sudo apt-get -s upgrade
Read the Installed and Candidate versions, and the repository address and branch of the candidate. At the time of the exercise, the security repository candidate and the tzdata candidate from trixie-updates were both present. This is an example of distinguishing actual sources rather than treating all updates as a single type. The candidate list varies depending on the time of execution.
Debian Security FAQ explains how security fixes are reflected in stable releases and the importance of exact Debian package versions and change history. An older upstream version number does not by itself show that Debian security fixes are missing. If necessary, check the target source packages and fixed versions in Debian Security Announcements and review all installed related binary packages.
Prepare Recovery and Apply One Controlled Update
Plan a maintenance window, a tested recovery method and console access for production servers. In the dedicated lab, the VM was shut down normally, a before-security-lab snapshot was created in VirtualBox, and the VM was restarted. A snapshot on the same storage is not an independent backup that survives loss of that device.
In the practice, after confirming that zlib1g is already installed and there is a new candidate in the security repository, the following plan was read. If this package is missing or the candidate is different, do not expect the same results and reselect your target package.
dpkg-query -W zlib1g
sudo apt-get -s install --only-upgrade zlib1g
sudo apt install --only-upgrade zlib1g
dpkg-query -W zlib1g
systemctl is-active ssh
systemctl --failed --no-pager
The --only-upgrade option restricts the named target to upgrading an already installed package; still read dependency changes and any proposed removals. In the Debian 13.7 lab, zlib1g changed from 1:1.3.dfsg+really1.3.1-1+b1 to the security-repository candidate 1:1.3.dfsg+really1.3.1-1+deb13u1. No packages were newly installed or removed in that operation. These are recorded lab versions, not instructions to pin a future installation to them.
Applying just this one example does not mean that the system's security updates are complete. Other candidates and pending items should also be reviewed according to your management plan. Even if library files are updated, already running processes may be using the previous version, so a separate decision for restart is necessary.
Back Up Policy and Install unattended-upgrades
Before installing the automation tool, back up the current configuration and record the timer state. Run the first directory-creation line separately and continue only if it succeeds. If that backup already exists, choose a fresh name and adjust all related paths. Stop on any failed step before making further changes.
sudo test ! -e /var/backups/lf-debian13-11 && sudo install -d -m 700 /var/backups/lf-debian13-11
sudo cp -a /etc/apt/apt.conf.d /var/backups/lf-debian13-11/
systemctl list-timers --all --no-pager apt-daily.timer apt-daily-upgrade.timer
sudo apt-get -s install --no-install-recommends unattended-upgrades
sudo apt install --no-install-recommends unattended-upgrades
In the exercise, unattended-upgrades 2.12 and the required python3-dbus and python3-distro-info were added. On servers where these are already installed, you must first read the current policy. Do not overwrite existing operational allow-lists or multi-repository policies with the example.
cat /etc/apt/apt.conf.d/50unattended-upgrades
apt-config dump | grep -E 'Origins-Pattern|Allowed-Origins|Automatic-Reboot|APT::Periodic'
sudo test ! -e /etc/apt/apt.conf.d/99-lf-security
The Debian package’s default configuration source includes allowances not only for the security branch but also for the main release. The following example is intended to learn an explicit policy that automates only the trixie-security source. Whether to maintain the default policy or also allow regular stable release updates should be determined according to operational requirements.
Set Allowed Origins, Intervals and Reboot Policy
If no new file exists, create it as sudo nano /etc/apt/apt.conf.d/99-lf-security and put the following complete content into it. If the existing 99-lf-security exists, do not replace it without separate review.
#clear Unattended-Upgrade::Origins-Pattern;
#clear Unattended-Upgrade::Allowed-Origins;
Unattended-Upgrade::Origins-Pattern {
"origin=Debian,codename=trixie-security,label=Debian-Security";
};
Unattended-Upgrade::Automatic-Reboot "false";
Unattended-Upgrade::Remove-Unused-Dependencies "false";
Unattended-Upgrade::Remove-New-Unused-Dependencies "false";
APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Unattended-Upgrade "1";
The #clear here is an APT configuration directive, not a terminal prompt. Merely adding a new list does not remove earlier entries. The two #clear directives clear the existing configuration lists before defining this policy; they do not delete files. The apt.conf manual explains list initialization and the order of reading configuration files. Do not omit quotation marks, semicolons, or braces.
| Selection | Effect | Items to judge separately |
|---|---|---|
| Matching source, codename, and label | Only allow candidates matching trixie-security | Items on hold due to dependencies and updates from other sources |
| Update-Package-Lists 1 | Daily list update conditions | Timer execution, network, update failure status |
| Unattended-Upgrade 1 | Daily automatic upgrade conditions | Allowed policies and actual installation logs |
| Automatic-Reboot false | Automatic reboot not allowed | Administrator service restart, scheduled reboot |
| Dependency package auto-clean false | Reduced the automatic deletion scope in practice | Manual review and later cleanup remain separate tasks |
Due to strict security origin restrictions, updates may be postponed if the required dependency combinations do not match. To address this, do not allow all external repositories and review the candidate dependencies and policies. This setting also does not constitute a policy to automatically switch to a new major version of Debian.
Inspect the Dry Run and Compare Package State
After saving, first read the merged settings and run a dry-run. The dry-run does not actually install packages but can operate on the list, cache, and logs. Run it at times that do not overlap with other package management operations and do not forcibly proceed by removing lock files.
apt-config dump | grep -E 'Origins-Pattern|Allowed-Origins|Automatic-Reboot|APT::Periodic'
dpkg-query -W -f='${binary:Package}\t${Version}\t${db:Status-Status}\n' | sudo tee /var/backups/lf-debian13-11/packages-before-dry.tsv > /dev/null
sudo unattended-upgrade --dry-run --debug
dpkg-query -W -f='${binary:Package}\t${Version}\t${db:Status-Status}\n' | sudo tee /var/backups/lf-debian13-11/packages-after-dry.tsv > /dev/null
sudo diff -u /var/backups/lf-debian13-11/packages-before-dry.tsv /var/backups/lf-debian13-11/packages-after-dry.tsv
Read the allowed origins and target packages to verify that the allow policy matches the intention. In practice, only candidates from the permitted security repository were selected, and tzdata from trixie-updates was not selected. The package list remained the same before and after the dry-run. Since result phrases like 'All upgrades installed' can appear in the dry-run log, this phrase alone is not used to determine that the packages were actually installed.
unattended-upgrade manual explains the --dry-run option and the log path. After checking the settings, you can use sudo unattended-upgrade --verbose during maintenance time to run it once for real, but keep in mind that this command actually updates the permitted targets, so do not confuse it with the dry-run command. In this practice, the only actual application was the previously confirmed zlib1g package, and it does not claim to have automatically installed all candidates.
Check Timers, Logs and Restart Requirements
Periodic execution in a systemd environment is linked with the APT timer. Do not just check whether unattended-upgrades.service is enabled, but also check the APT timer and periodic settings.
systemctl is-enabled apt-daily.timer apt-daily-upgrade.timer
systemctl is-active apt-daily.timer apt-daily-upgrade.timer
systemctl cat apt-daily-upgrade.timer
systemctl list-timers --all --no-pager apt-daily.timer apt-daily-upgrade.timer
sudo journalctl -u apt-daily-upgrade.service -b --no-pager -n 50
sudo tail -n 40 /var/log/unattended-upgrades/unattended-upgrades.log
The lab’s apt-daily-upgrade.timer used a 06:00 schedule, up to 60 minutes of randomized delay and Persistent behavior. These settings do not promise completion at 06:00: actual execution depends on timer and system state. To enable the timers under your chosen policy, run sudo systemctl enable --now apt-daily.timer apt-daily-upgrade.timer and inspect the next scheduled run and subsequent execution logs.
If there are no logs, distinguish between cases where it has not run yet and issues with the log path or permissions. Detailed records of the installation process can also be checked in /var/log/unattended-upgrades/unattended-upgrades-dpkg.log. If you only performed a dry run, do not expect the actual installation logs to be filled. Even if you set up email notifications, a separate functioning mail-sending environment is required.
If you have updated the kernel package, check the running kernel separately with uname -r. Installing a new kernel file does not immediately change the current kernel. The presence of /run/reboot-required can be noted, but the absence of that file does not mean that all restarts are unnecessary. Check the application conditions for libraries, services, and the kernel.
On the dedicated VM, after updating zlib, we confirmed a successful reboot and new SSH connection. If there are production services, do not stop at checking connections after reboot; inspect service responses, data access, logs, and scheduled tasks according to each service's normal standards.
Stop Automatic Installation and Understand Recovery Limits
To temporarily stop automatic installation during practice, change the setting from APT::Periodic::Unattended-Upgrade "1"; to "0" and query the combined value again. Simply deleting a custom file may cause the active settings of other files to be reapplied.
sudo nano /etc/apt/apt.conf.d/99-lf-security
apt-config dump | grep 'APT::Periodic::Unattended-Upgrade'
For this VM, after verification, we also changed the automatic installation value to 0 to prevent arbitrary changes during subsequent practice, while keeping the timer itself in its original active state. On actual servers, do not leave security maintenance gaps, and set the stop period, the person responsible for manual updates, and the schedule.
When reverting settings to a previous policy, compare the backup with the current files and restore only the scope you added. Policy recovery does not mean rolling back already installed packages to a previous version. Restoring a snapshot of a dedicated VM may also result in losing subsequent changes to settings, files, and data, so first separate the data you want to preserve, and on production servers, use verified backups and recovery plans for each service.




