Disable Auto Updates (Unattended Upgrades) in Ubuntu

PowerADM.com / Linux / Ubuntu / Disable Auto Updates (Unattended Upgrades) in Ubuntu

On Ubuntu Server 18 and newer, the unattended-upgrades package is installed by default. This package is used to automatically install all updates or just security updates in Ubuntu.

#dpkg -l | grep unattended-upgrades

unattended-upgrades on ubuntu used to automatically install updates

It is thanks to this package that you may encounter this message when you shutdown/reboot Ubuntu:

Unattended-upgrade in progress during a shutdown, please don’t turn off the computer

ubuntu: Unattended-upgrade in progress during shutdown, please don’t turn off the computer

Automatic update check and installation settings in Ubuntu/Debian are configured in /etc/cron.daily/apt. The file is run from /etc/crontab by default at 06:25. So, if something breaks down around this time, you know who is to blame.

To completely remove the unattended-upgrade package and all of its components:

$ sudo apt-get -y remove unattended-upgrades
$ sudo systemctl stop apt-daily.timer
$ sudo systemctl disable apt-daily.timer
$ sudo systemctl stop apt-daily-upgrade.timer
$ sudo systemctl disable apt-daily-upgrade.timer
$ sudo systemctl disable apt-daily.service
$ sudo systemctl daemon-reload

Or, you can disable automatic updates for Ubuntu in the file:

$ sudo vi /etc/apt/apt.conf.d/20auto-upgrades

APT::Periodic::Unattended-Upgrade "0";
APT::Periodic::Update-Package-List "0";

If you do decide to configure automatic updates in Ubuntu through automatic updates, use the command:

$ sudo dpkg-reconfigure unattended-upgrades

configure unattended-upgrades on Ubuntu

In the /etc/apt/apt.conf.d/50unattended-upgrades file, you can specify which updates you want to install automatically:

Unattended-Upgrade::Allowed-Origins {
        "Ubuntu precise-security";
//      "Ubuntu precise-updates";

You can prevent the automatic update of certain packages:

Unattended-Upgrade::Package-Blacklist {
//    "libc6-i686";

To enable automatic updates in apt settings, add the following options to the /etc/apt/apt.conf.d/20auto-upgrades file:

APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Download-Upgradeable-Packages "1";
APT::Periodic::AutocleanInterval "7";
APT::Periodic::Unattended-Upgrade "1";

With these settings, the Ubuntu server will check for updates and install them daily.

The unattended-upgrades log is stored in the /var/log/unattended-upgrades file.

Leave a Reply

Your email address will not be published. Required fields are marked *