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.
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.
Disable Automatic Updates via GUI
1. First, open up the “Software & Updates” utility.
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.
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";
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 "127.0.0.1 api.snapcraft.io" >> /etc/hosts
Your solution still does not prevent snaps from updating.
Thanks for pointing that out. We’ve updated the article to include disabling Snap package updates.
NIce, what if we change our mind and we now want the updates setting back?
Thanks for the suggestion. We’ve updated the article to show how to re-enable automatic updates.
Hello, thanks for the article. A few additional questions:
Are the GUI and command line options equivalent? I’ve been using the GUI method for years, but still get an icon in the upper right which tells me it is still checking even with “Automatically check for update” set to “Never”. I’m wondering if the command line option will truly shut it down (except for manual updates of course).
For snap I’m a bit confused. Since it’s automatic by default and no official command to stop it, how would we know if it’s been used? I use a minimal install for a single, low-security, internal app, and I’ve only ever run the regular updates manually. Or is there a way to find out before we remove it? Thanks for the additional help.
—
After looking at the auto-upgrades file, I see the Unattended-Upgrade directive is still at “1”. Maybe setting it to zero (i.e., using the command line method) would shut down the periodic check for good, except for snap?
The GUI option doesn’t allow you to stop security updates, which is probably why you still see it wanting to update. Setting the directives via command line will be a more surefire method. Ubuntu doesn’t like to make this easy.
For Snap, you can see the last time it updated with
snap refresh --time
. It will also show when it’s scheduled to check for updates again.And the answer to your last question is yes, that’s how it should work. If not, feel free to report back! Thanks.
I just want to personally reach out and say thank you. I’m actually shocked that so many websites that have dealt with Ubuntu for years were regurgitating the same advice via GUI or some editing of the apt.conf.d file and it still wasn’t working. You went a step further and showed how to remove/suppress the service.
I’m equally shocked that Ubuntu does not allow users to have more control over their update stack. What’s the point if they are going to be Microsoft-like with their update policies.
Thanks for the comment, Jon. Yes, it’s weird that we have to do this configuration just to disable updates. Ubuntu definitely wants to force them on users.
Thank you.
Excellent article, and very helpful.
Thank you very helpful article.
You and your work are great! I always love Linux for being intuitive and easy to set up. And now… I should say I saw Windows 11, and it kinda nice looking and have some Linux feel somehow. And now all major Linux projects have a lot of trouble to set simple things up. Yes there always were some trouble with Linux and Windows. But in Linux you always could solve trouble with command line utilities. It was always easy. And now this all going somewhere. For example no way to tune libinput in wayland in real time, and there are some hacky way to do it in config before loading, and it also does not cover all properties.
And now that snap firefox packaging. Even if you install deb firefox, it autoupdates to snap again. Thank you very much, for your instruction of update disable. I always updated my system manually, and never like this Windows idea of “please wait while your PC doing its own things” when you are in a hurry. But with this tendency, I am afraid of returning to Windows… As Linux starts to became even more evil.
Most of these annoyances, like auto updates, are unique to Ubuntu. Canonical has a track record for pushing unwanted features on the userbase, and sometimes reverts them later. I still like Ubuntu, but it’s understandable that some users are getting tired of these “features” and migrate to something else.