Unattended Upgrades software helps us auto-update and upgrade system packages in the background without user interaction to keep up to date with the latest features and security patches.
This feature can be a handful to secure your system with the latest security issues, even ubuntu providing it out of the box with its latest iso.
Unexpected background updates can be irritating for regular Linux users. At the time of background update, if you try to install any package or attempt to execute the apt command, you will get a similar error as shown below.
Waiting for cache lock: Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 3082 (unattended-upgrades)
Today, you will learn four different ways to disable auto-update & upgrade in the background for Debian and Ubuntu operating systems.
Method 1: Disabling from Configuration files
The first and foremost method is disabling the auto-upgrade feature from the unattended-upgrades configuration file located at “/etc/apt/apt.conf.d/50unattended-upgrades” using any of your favorite text editors as shown below.
$ sudo nano "/etc/apt/apt.conf.d/50unattended-upgrades"
After executing the above command, you need to focus on two-line shown below.
By default, auto-update and upgrade; the option is enabled in unattended-upgrades. You can change the value depending upon your own need.
If you want to auto-update your system repositories without upgrading the packages, change the values as shown below.
If you want to upgrade packages with the latest available version in the fetched repositories, change the values as shown below.
Note: This scenario might be less effective as next auto upgrade will stop because latest repositories fetched version is already installed in your system.
To disable both updates and upgrade in your system, change the values as shown below.
Save the file to make all changes reflected adequately.
Method 2: dpkg-reconfiguring the unattended-upgrades
If you want to stop auto-update and upgrade right after the installation, you can use the “dpkg-reconfigure” command to disable auto-update and upgrade, as shown below.
$ sudo dpkg-reconfigure unattended-upgrades
After executing the above command zenity dialog box will prompt, click <No> to prevent automatic update and upgrade.
After selecting <No>, press enter to disable auto-update and upgrade on your ubuntu system.
Method 3: Graphical Method to Enable/Disable Auto Update & Upgrade
If you prefer to use the graphical method to disable automatic update and upgrade on Ubuntu operating system.
Then open the “Software & Updates” from the activity search bar and navigate to the “Updates” section.
From here, change “Automatically check for updates” from “daily” to “never,” as shown below.
Method 4: Remove unattended-upgrades package
If any of the above methods didn’t work for you, remove the unattended upgrades from your system, as shown below.
#Use below command if you just want to remove package binary
$ sudo apt remove unattended-upgrades
#Use below command if you want to remove package binary along with the configuration files
$ sudo apt purge unattended-upgrades
Should you disable the automatic update and upgrade feature?
This feature is being provided by default for an important reason, security issues. There are always be some new security flaws captured requiring you to install the latest security patches for your system to prevent any security issues.
Innovative tech mind with 12 years of experience working as a computer programmer, web developer, and security researcher. Capable of working with a variety of technology and software solutions, and managing databases.