Unattended upgrades =================== This script upgrades packages automatically and unattended. If you would prefer to disable it from the command line, run "sudo dpkg-reconfigure -plow unattended-upgrades". It will not install packages that require dependencies that can't be fetched from allowed origins, and it will check for conffile prompts before the install and holds back any package that requires them. Setup ----- By default unattended-upgrades runs an update every day. The main way to specify which packages will be auto-upgraded is by means of their "origin" and "archive". These are taken respectively from the Origin and Suite fields of the repository's Release file, or can be found in the output of: ``` $ apt-cache policy ``` in the "o" and "a" fields for the given repository. The default setup auto-updates packages in the main and security archives, which means that only stable and security updates are applied. This can be changed either with the "Unattended-Upgrade::Allowed-Origins" or the "Unattended-Upgrade::Origins-Pattern" apt configuration lists, which are listed in /etc/apt/apt.conf.d/50unattended-upgrades. Also in this file are a range of other options that can be configured. To override the configuration it is recommended to create a separate APT configuration file fragment which overrides the shipped default value because updates to the shipped configuration file may conflict with the local changes blocking updating unattended-upgrades itself. The new file should sort later than 50unattended-upgrades to be parsed later than the one shipping the default values, it can be e.g. 52unattended-upgrades-local. Allowed-Origins is a simple list of patterns of the form "origin:archive". Origins-Pattern allows you to give a list of (glob-style) patterns to match against. For example: ``` Unattended-Upgrade::Origins-Pattern { "origin=Google\, Inc.,suite=contrib"; "site=www.example.com,component=main"; }; ``` will upgrade a package if either the origin is "Google, Inc." and suite is "contrib" or if it comes from www.example.com and is in component "main". The apt-cache policy short identifiers (e.g. "o" for "origin") are also supported. Note that, to properly override lists such as Origins-Pattern, you must first clear the stock-provided list before inserting your own. Otherwise, your custom origins will instead be allowed *in addition to* the stock values. For example, if you only want to allow the 'debian-security' origin, the 52unattended-upgrades-local file should contain something like this: ``` #clear Unattended-Upgrade::Origins-Pattern; Unattended-Upgrade::Origins-Pattern { "origin=Debian,codename=${distro_codename},label=Debian-Security"; "origin=Debian,codename=${distro_codename}-security,label=Debian-Security"; }; ``` If you already configured what to install via apt pinning, you can simply use "origin=*", e.g.: ``` Unattended-Upgrade::Origins-Pattern { "origin=*"; }; ``` All operations are logged in /var/log/unattended-upgrades/. This includes the dpkg output as well. The file /etc/logrotate.d/unattended-upgrades controls how long logfiles are kept, and how often they are rotated. See the `logrotate` manpage for details. If you want mail support you need to have a mail-transport-agent (e.g postfix) or mailx installed. Following Debian testing ------------------------ unattended-upgrades can keep a Debian testing system continuously up to date without ever removing a package. Every upgrade step is checked first and held back if it would remove a package (e.g. in a library transition), install from a not allowed or untrusted origin, cause a conffile prompt or leave broken dependencies. With the default `Unattended-Upgrade::MinimalSteps "true"` each self-contained set of packages is checked, downloaded and installed on its own. Packages that are stuck in a transition are kept back while the rest of the system is upgraded; they are retried on every run and installed once the transition has finished. To follow testing, add e.g. /etc/apt/apt.conf.d/52unattended-upgrades-local: ``` #clear Unattended-Upgrade::Origins-Pattern; Unattended-Upgrade::Origins-Pattern { "origin=Debian,archive=testing,label=Debian"; "origin=Debian,archive=testing-security,label=Debian-Security"; }; ``` Matching on the archive keeps following testing across releases. To stay on the current release once it becomes stable, match on `codename=${distro_codename}` instead, like the default configuration does. After a successful upgrade unattended-upgrades by default autoremoves packages that became unused (`Remove-New-Unused-Dependencies`) and automatically installed kernels that are no longer running (`Remove-Unused-Kernel-Packages`), i.e. what `apt autoremove` would remove. To never remove anything, disable both; old kernels then accumulate in /boot until removed manually: ``` Unattended-Upgrade::Remove-New-Unused-Dependencies "false"; Unattended-Upgrade::Remove-Unused-Kernel-Packages "false"; ``` Also useful on testing: * `Unattended-Upgrade::Allow-APT-Mark-Fallback "false";` - faster runs when many packages are not installable, at the cost of a few more kept back packages. * `Dpkg::Options {"--force-confold"};` - packages with conffile prompts are upgraded instead of held back; the local configuration file is kept and the new one installed as `.dpkg-dist`. * `Unattended-Upgrade::Automatic-Reboot` - kernel and libc upgrades are frequent on testing. To see what would be done and why packages are kept back, run `sudo unattended-upgrade --dry-run --debug` and look for "sanity check failed" in /var/log/unattended-upgrades/unattended-upgrades.log. Debugging --------- If something goes wrong, or if you want to report a bug about the way the script works, it's a good idea to run: ``` $ sudo unattended-upgrade --debug --dry-run ``` and look at the resulting logfile in: /var/log/unattended-upgrades/unattended-upgrades.log It will also contain additional debug information. Manual Setup ------------ To activate this script manually you need to ensure that the apt configuration contains the following lines (this can be done via the graphical "Software Source" program or via dpkg-reconfigure as well): ``` APT::Periodic::Update-Package-Lists "1"; APT::Periodic::Unattended-Upgrade "1"; ``` This means that it will check for updates every day, and install them (if that is possible). If you have update-notifier installed, it will setup /etc/apt/apt.conf.d/10periodic. Just edit this file then to fit your needs. If you do not have this file, just create it or create/edit /etc/apt/apt.conf - you can check your configuration by running "apt-config dump". Plugin support -------------- Plugin support is available to integrate with webhooks or other custom tools that need to read u-u run results. Check the [example plugin](https://github.com/mvo5/unattended-upgrades/blob/main/examples/plugins/simple.py) in the git repository for more details. Supported Options Reference --------------------------- * `Unattended-Upgrade::Allowed-Origins` - list of (origin:archive) pairs Only packages from this origin:archive pair will be installed. You can see all available origin:archive pairs by running `apt-cache policy` and checking the "o=" and "a=" fields. Variable substitution is supported for ${distro_id} that contains the distribution ID (e.g. "Debian" or "Ubuntu"), ${distro_codename} that contains the release codename (e.g. "trixie" or "noble") and ${distro_release} that contains the release version (e.g. "13" or "24.04"). These values are read from os-release(5), see the `ID`, `VERSION_CODENAME` and `VERSION_ID` fields. Example: ``` Unattended-Upgrade::Allowed-Origins { "${distro_id}:${distro_codename}-security"; ``` * `Unattended-Upgrade::Package-Blacklist` - list of regular expressions No packages that match the regular expressions in this list will be marked for upgrade. If a package A has a blacklisted package B as a dependency then both packages A and B will not be upgraded. Note that it's a list of regular expressions, so you may need to escape special characters like "+" as "\\+". Example: Any package with the "vim" prefix, including `vim` and `vim-doc`. ``` Unattended-Upgrade::Package-Blacklist { "vim"; }; ``` Example: Only the exact `libstdc++6` package. ``` Unattended-Upgrade::Package-Blacklist { "libstdc\+\+6$"; }; ``` * `Unattended-Upgrade::Package-Whitelist` - list of regular expressions Only packages that match the regular expressions in this list will be marked for upgrade. By default dependencies of whitelisted packages are allowed. This can be changed to only ever allow whitelisted packages with the `Unattended-Upgrade::Package-Whitelist-Strict` boolean option. `Unattended-Upgrade::Package-Blacklist` still applies, thus blacklisted packages covered by the whitelist will still not be upraded nor will be installed or upgraded as dependencies of whitelisted packages. Example: ``` Unattended-Upgrade::Package-Whitelist { "bash"; }; ``` * `Unattended-Upgrade::Package-Whitelist-Strict` - boolean (default:False) When set, allow only packages in `Unattended-Upgrade::Package-Whitelist` to be upgraded. This means that you also need to list all the dependencies of a whitelisted package, e.g. if A depends on B and only A is whitelisted, it will be held back. Example: ``` Unattended-Upgrade::Package-Whitelist-Strict "true"; ``` * `Unattended-Upgrade::AutoFixInterruptedDpkg` - boolean (default:True) Run `dpkg --force-confold --configure -a` if a unclean dpkg state is detected. This defaults to true to ensure that updates get installed even when the system got interrupted during a previous run. It is not done with `--dry-run` or `--download-only`, nor while another package manager holds the dpkg frontend lock. With `InstallOnShutdown` it is left to the run at shutdown. * `Unattended-Upgrade::MinimalSteps` - boolean (default:True) Optimize for safety against e.g. power failure by performing the upgrade in minimal self-contained chunks. This also allows sending a SIGTERM to unattended-upgrades, and it will stop the upgrade when it finishes the current upgrade step. * `Unattended-Upgrade::InstallOnShutdown` - boolean (default:False) Perform the upgrade when the machine is shutting down instead of doing it in the background while the machine is running. The shutdown waits for the upgrade at most for logind's `InhibitDelayMaxSec`, which unattended-upgrades sets to 30 seconds, then the upgrade is stopped and what is left is installed on a later shutdown. To allow more time, put a file with the same name as the one of unattended-upgrades in `/etc/systemd/logind.conf.d/`. A setting in `/etc/systemd/logind.conf`, or in a drop-in whose name sorts before `unattended-upgrades-logind-maxdelay.conf`, has no effect because the file of unattended-upgrades is read after it: ``` # /etc/systemd/logind.conf.d/unattended-upgrades-logind-maxdelay.conf [Login] InhibitDelayMaxSec=30min ``` * `Unattended-Upgrade::MinBatteryLevel` - percentage or "ac-only" (default:"40") The average charge of the batteries, in percent, needed to upgrade while the machine is running on battery. Below that, the upgrade is skipped or gracefully stopped. Set it to "0" to upgrade regardless of power source, or to "ac-only" to only upgrade on AC power. With `Unattended-Upgrade::MinimalSteps`, the power is checked before each upgrade step. If this isn't set but the legacy boolean `Unattended-Upgrade::OnlyOnACPower` is, "true" works like "ac-only" and "false" like "0". * `Unattended-Upgrade::Mail` - string (default:"") Send an email to this address with information about the packages upgraded. If empty or unset no email is sent. This option requires a working local mail setup. Example: ``` Unattended-Upgrade::Mail "user@example.com"; ``` * `Unattended-Upgrade::Sender` - string (default:"root") Use the specified value in the "From" field of outgoing mails. Example: ``` Unattended-Upgrade::Sender "server@example.com"; ``` * `Unattended-Upgrade::MailReport` - string (default: "on-change") Possible values are: - "always": mail after every run, even when nothing had to be done. - "only-on-error": mail only when the run failed. - "on-change": mail when packages were upgraded or removed, on error, and on every run while packages are kept back (for example blacklisted or on hold), even when nothing else happened. - "on-new-change": like "on-change", but a package that stays kept back is reported once, and again only when a new version of it is kept back, or when it is kept back again after it was not; the versions already reported are saved in `/var/lib/unattended-upgrades/kept-back-mailed`. - "on-upgrade": mail only when packages were upgraded or removed, or on error; packages that are kept back are listed in those mails, but never trigger a mail by themselves. If this value is not set then the value is set by using the legacy option `Unattended-Upgrade::MailOnlyOnError` (default:False) to choose between "only-on-error" and "on-change". NOTE that "never" is achieved by not setting any `Unattended-Upgrade::Mail` * `Unattended-Upgrade::Remove-Unused-Kernel-Packages` - boolean (default:True) Remove unused automatically installed kernel-related packages (kernel images, kernel headers and kernel version locked tools) before upgrading, to avoid filling /boot or the root file system. * `Unattended-Upgrade::Remove-Unused-Dependencies` - boolean (default:False) Remove all unused dependencies after the upgrade has finished. * `Unattended-Upgrade::Remove-New-Unused-Dependencies` - boolean (default:True) Remove only the packages that became unused as a result of this upgrade. Has no effect when `Unattended-Upgrade::Remove-Unused-Dependencies` is enabled, since that removes them too. * `Unattended-Upgrade::Automatic-Reboot` - boolean (default:False) Automatically reboot *WITHOUT CONFIRMATION* if the file /var/run/reboot-required is found after the upgrade. * `Unattended-Upgrade::Automatic-Reboot-WithUsers` - boolean (default:True) Automatically reboot even if users are logged in. When set to false, the logged in users are checked only when unattended-upgrades schedules the reboot: with a later `Unattended-Upgrade::Automatic-Reboot-Time`, users who log in after that do not block it, and a later run that finds them logged in does not cancel it. With systemd, new logins of unprivileged users are refused in the last 5 minutes before the reboot (see `shutdown(8)`). * `Unattended-Upgrade::Automatic-Reboot-Time` - time (default:"now") If automatic reboot is enabled and needed, reboot at the specific time instead of immediately. The value is passed to `shutdown -r`, see `shutdown(8)` for the accepted formats. Example - reboot at 02:00: ``` Unattended-Upgrade::Automatic-Reboot-Time "02:00"; ``` * `Unattended-Upgrade::Keep-Debs-After-Install` - boolean (default:False) Keep the downloaded deb packages after successful installs. By default these are removed after successful installs. * `Acquire::http::Dl-Limit`, `Acquire::https::Dl-Limit` - integer (default:0) Use apt bandwidth limit feature, the number is how many KiB/s apt is allowed to use. These apt options (see `apt-transport-http(1)`) apply to all apt downloads, not only to unattended-upgrades. `Acquire::http::Dl-Limit` also limits https sources, but apt then downloads from several https servers in parallel, each at the limit; set `Acquire::https::Dl-Limit` too to download from one at a time. Example - limit the download to 70 KiB/s: ``` Acquire::http::Dl-Limit "70"; Acquire::https::Dl-Limit "70"; ``` * `Dpkg::Options` - list of strings Set a dpkg command-line option. This is useful to e.g. force conffile handling in dpkg. Example - force dpkg to keep the old configuration files: ``` Dpkg::Options {"--force-confold"}; ``` Note that unattended-upgrades detects this option, and ensures that packages with configuration prompts will never be held back. * `Unattended-Upgrade::Update-Days` - list of strings (default:empty) Set the days of the week that updates should be applied. The days can be specified as localized abbreviated or full names. Or as integers where "0" is Sunday, "1" is Monday etc. Example - apply updates only on Monday and Friday: ``` Unattended-Upgrade::Update-Days {"Mon";"Fri"}; ``` The default is an empty list which means updates are applied every day. * `Unattended-Upgrade::SyslogEnable` - boolean (default:False) Write events to syslog, which is useful in environments where syslog messages are sent to a central store. Example - Enable writing to syslog: ``` Unattended-Upgrade::SyslogEnable true; ``` The default is False - events will not be written to syslog. * `Unattended-Upgrade::SyslogFacility` - string (default:"daemon") Write events to the specified syslog facility, or the daemon facility if not specified. Requires the `Unattended-Upgrade::SyslogEnable` option to be set to true. Example - Use the syslog auth facility: ``` Unattended-Upgrade::SyslogFacility "auth"; ``` The default is the daemon facility. ![](https://github.com/mvo5/unattended-upgrades/workflows/build/badge.svg)