How to Disable Automatic Updates in Ubuntu

Ubuntu has automatic updates enabled by default. Ordinarily, this is a convenient feature that helps our system stay up to date with the latest features, and protected with the newest security patches. However, on test systems or in edge cases, it can just be plain annoying.

In this article, we’ll show you how to disable automatic updates in Ubuntu. This can be done from either GUI or command line, and we’ll show you both methods in this guide.

By disabling automatic updates, you assume the risk of your system falling out of date and susceptible to security risks. You should only disable automatic updates on test machines.

Personally, we prefer to disable automatic updates on test machines in order to prevent the could not get lock error, which is caused by trying to use the package manager to install software when the system is already using the process to check for updates.

Could not get lock error on Ubuntu

Disable Automatic Updates via GUI

1. First, open up the “Software & Updates” utility.

Opening software & updates utility on Ubuntu

2. Head over to the “updates” tab and change the “automatically check for updates” option to never. Once you’ve made the changes, you can close this window.

Disabling automatic updates in software updates utility

Disable Automatic Updates via Command Line

1. Update preferences are stored in the /etc/apt/apt.conf.d/20auto-upgrades file. Open it with nano or your favorite text editor to make some changes to it.

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

2. To disable automatic updates completely, make sure all these directives are set to “0”. When done, save your changes and exit the file.

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

Editing the automatic upgrades file

That’s all there is to it. Now you won’t need to worry about Ubuntu holding the apt package manager hostage when you try to use it. Upgrades and package downloads are now under your complete control, so don’t forget to manually update your system every once in a while.

In case you want to re-enable automatic updates, just change the directives back to “1”.

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

Remove unattended-upgrades Package

It’s also possible to remove the unattended-upgrades package completely from your system. This is only recommended for system administrators who have a strong understanding of the risks involved.

$ sudo apt purge --auto-remove unattended-upgrades

And then disable the system upgrade timers left behind.

$ sudo systemctl disable apt-daily-upgrade.timer
$ sudo systemctl mask apt-daily-upgrade.service
$ sudo systemctl disable apt-daily.timer
$ sudo systemctl mask apt-daily.service

If you need to re-enable automatic updates, you can reinstall the unattended-upgrades package and enable the upgrade timers with the following commands:

$ sudo apt install unattended-upgrades

$ sudo systemctl enable apt-daily-upgrade.timer
$ sudo systemctl unmask apt-daily-upgrade.service
$ sudo systemctl enable apt-daily.timer
$ sudo systemctl unmask apt-daily.service

Disable Snap Updates

By default, the Snap package manager on Ubuntu will check for updates 4 times per day. Snap calls these updates a “refresh,” but they are essentially an update check which will upgrade your Snap packages in the background.

To see this on your own system, you can run the following command.

$ snap refresh --time

timer: 00:00~24:00/4
last: yesterday at 22:29 EDT
next: today at 04:10 EDT

The output above shows that snapd is configured to check for updates 4 times each day, and also shows the last time it checked for updates, and when it plans to check for updates again.

There’s no official command to permanently disable Snap updates. But we still have a few options to disable Snap refreshes/updates, as you’ll see below.

Option 1. If you’re not actually using the Snap package manager, then you can just remove it from your system completely, which will obviously stop any updates as well.

$ sudo apt purge --auto-remove snapd

Option 2. Stop the snapd service from running on Ubuntu by configuring systemd with the following commands.

$ sudo systemctl stop snapd.service
$ sudo systemctl stop snapd.socket

If you want to make sure these changes persist after a reboot, you’ll need to also disable the services by running the commands below.

$ sudo systemctl mask snapd.service
$ sudo systemctl mask snapd.socket

If at any point you need to revert these changes, and check for Snap updates, run these commands.

$ sudo systemctl unmask snapd.service
$ sudo systemctl unmask snapd.socket
$ sudo systemctl start snapd.service
$ sudo snap refresh

Option 3. We can edit the /etc/hosts file to block network access to the Snap store. Snap will try to check for updates in the background, but it will always be unsuccessful until this line is removed.

$ sudo echo "" >> /etc/hosts

If our content helped you, please consider buying us a coffee. We appreciate your support!

Buy me a coffee donation button

4 thoughts on “How to Disable Automatic Updates in Ubuntu”

    1. Thanks for pointing that out. We’ve updated the article to include disabling Snap package updates.

Leave a Comment

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