Ubuntu Turn Off Automatic Updates From CLI with Best 3 Steps

Posted on

Ubuntu Turn Off Automatic Updates From CLI with Best 3 Steps

Ubuntu Turn Off Automatic Updates From CLI with Best 3 Steps

This tutorial will guide you on how to "Ubuntu Turn Off Automatic Updates From the Command line." As you likely know, automatic updates in Ubuntu keep your system current and secure. However, there might be situations where you need manual control over these updates. One common reason is that automatic updates can disrupt ongoing work. In such instances, disabling automatic updates in Ubuntu becomes necessary. This article details how to "Ubuntu Turn Off Automatic Updates From the Command line".

You can follow these guide steps on the Orcacore website to complete Ubuntu Turn Off Automatic Updates From the Command line.

Guide Steps For Ubuntu Turn Off Automatic Updates From The Command Line

To avoid potential problems and interruptions to your work, and to better manage your services, it’s often preferable to manually disable automatic updates in Ubuntu. To accomplish this, log in to your Ubuntu server, open a terminal, and follow the instructions below.

Step 1. Disable unattended-upgrade Ubuntu

The first step involves disabling Unattended Upgrades. This is a package Ubuntu uses for managing automatic updates. To disable it, open the following configuration file with your preferred text editor, such as Vi Editor or Nano Editor:

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

Within this file, you need to change the value of the automatic updates to "0". The value "0" indicates that automatic updates will be disabled.

Ubuntu Turn Off Automatic Updates

Once you have made the change, save and close the file.

Step 2. Disable Automatic Update Notifications Ubuntu

Now that you’ve learned to "Ubuntu Turn Off Automatic Updates" in Ubuntu, you might still receive notifications about available updates. To disable these notifications, run the following command:

sudo mv /etc/xdg/autostart/update-notifier.desktop /etc/xdg/autostart/update-notifier.desktop.disabled

This command renames the update notifier’s desktop file, effectively preventing it from starting automatically.

Step 3. Run Manual Update in Ubuntu

With automatic updates disabled, you can now manually update and upgrade your system using the following commands:

sudo apt update && sudo apt upgrade -y

This will update the package lists and then upgrade all installed packages to their latest versions.

Conclusion

Disabling automatic updates in Ubuntu gives you control over when your system is updated. While this offers more control, it also requires you to be proactive in maintaining your system’s security. Remember to check for updates regularly and install them to keep your system secure and running smoothly. Hopefully, you found this guide helpful.

You may also be interested in these articles:

Find Ubuntu Version and System Details

What sudo apt update and upgrade Do on Ubuntu / Debian

Ubuntu 24.04 LTS Desktop Installation

Set a Static IP Address on Ubuntu 24.04 Via GUI

Check and Install Security Updates on Ubuntu 22.04

Configure Automatic Kernel Updates on Linux

FAQs

Why should I turn off automatic updates in Ubuntu?

It gives you full control over updates. This is useful if you want to test updates first or avoid disruptions during important tasks.

How do I disable automatic updates using the command line?

As we discussed in the guide, you need to edit the /etc/apt/apt.conf.d/20auto-upgrades file and change the upgrade values to “0”.

Can I re-enable automatic updates later?

Yes, you can re-enable automatic updates by editing the same file and setting the values back to “1”.

Is it dangerous to turn off automatic updates in Ubuntu?

No. However, without updates, your system may become vulnerable to security threats and bugs. It’s important to manually check for and apply updates regularly.

Alternative Methods to "Ubuntu Turn Off Automatic Updates From CLI"

While the previous steps effectively disable automatic updates via the unattended-upgrades package, there are alternative approaches to achieve the same goal, providing greater flexibility and control.

Method 1: Using dpkg-reconfigure

The dpkg-reconfigure command provides an interactive way to configure already installed packages. This method allows you to directly configure the unattended-upgrades package and prevent it from running automatically.

Explanation:

dpkg-reconfigure prompts you with a series of questions related to the package you’re configuring. For unattended-upgrades, it asks if you want to enable automatic updates. By selecting "No", you effectively disable the automatic update process controlled by this package.

Steps:

  1. Open a terminal.
  2. Run the following command:
sudo dpkg-reconfigure unattended-upgrades
  1. A text-based user interface will appear. Use the arrow keys to navigate and select <No> when asked "Automatically download and install stable updates?".
  2. Press Enter to confirm your selection.

This method modifies the configuration files associated with unattended-upgrades, preventing it from automatically installing updates. It’s a cleaner approach than directly editing configuration files, as dpkg-reconfigure handles the necessary changes consistently.

Method 2: Masking the apt-daily.timer and apt-daily-upgrade.timer

Ubuntu uses systemd to manage various system services and timers. Two specific timers, apt-daily.timer and apt-daily-upgrade.timer, are responsible for triggering the update and upgrade processes. Masking these timers effectively prevents them from running, thus disabling automatic updates.

Explanation:

systemd masking is a more forceful way of disabling a service or timer. When a unit (service, timer, etc.) is masked, it becomes completely unavailable. Attempting to start a masked unit will fail. This ensures that the automatic update processes never initiate.

Steps:

  1. Open a terminal.
  2. Run the following commands:
sudo systemctl mask apt-daily.timer
sudo systemctl mask apt-daily-upgrade.timer
  1. To verify that the timers are masked, run:
systemctl status apt-daily.timer
systemctl status apt-daily-upgrade.timer

The output should indicate that the timers are masked and cannot be started.

Re-enabling Automatic Updates:

To re-enable automatic updates using this method, you need to unmask the timers:

sudo systemctl unmask apt-daily.timer
sudo systemctl unmask apt-daily-upgrade.timer
sudo systemctl enable apt-daily.timer
sudo systemctl enable apt-daily-upgrade.timer
sudo systemctl start apt-daily.timer
sudo systemctl start apt-daily-upgrade.timer

These commands unmask the timers, enable them to start on boot, and then immediately start them. The "Ubuntu Turn Off Automatic Updates" solution is useful in certain situations. This provides you more control over the system. This offers more control over the system’s update schedule and prevents unexpected interruptions. Remember to regularly check for updates manually to ensure your system remains secure.

Leave a Reply

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