How to Disable Ubuntu Pro Notifications During APT Operations

System administrators and developers using Ubuntu may encounter informational messages related to Ubuntu Pro when running package management commands such as apt update or apt upgrade.

A common message begins with “Try Ubuntu Pro beta with a free personal subscription…”. While intended to inform about available services, this output can be undesirable in automated scripts or for users preferring a cleaner terminal experience. This article details the origins of these messages and presents several methods to prevent their appearance.

Understanding the Source of Ubuntu Pro Messages

The package primarily generates these notifications. This package integrates with the Advanced Package Tool (APT) system through hook scripts. Specifically, a file named 20apt-esm-hook.conf located in /etc/apt/apt.conf.d/ is often responsible for triggering these messages during APT operations. The system may also use template files stored in directories like /var/lib/ubuntu-advantage/messages/ to construct the displayed text.

The ubuntu-advantage-tools package itself might be marked as a required system component, which can make its straightforward removal complex due to dependencies.

Solutions to Disable Ubuntu Pro APT Notifications

Several approaches can be employed to suppress these messages, ranging from configuration adjustments to package modifications. Root privileges are typically required for these operations.

methods to Disable Ubuntu Pro APT Notifications

Methods to Disable Ubuntu Pro APT Notifications

Read: How to Fix WIFI not working on Ubuntu 22.04

Method 1: Modifying the APT Hook Configuration File (20apt-esm-hook.conf)

Directly altering or neutralizing the 20apt-esm-hook.conf file can prevent it from executing and displaying messages. Below are a few techniques to achieve this. Remember to use sudo for commands that modify system files.

Technique A: Rename and Create an Empty File

Command:

sudo mv /etc/apt/apt.conf.d/20apt-esm-hook.conf /etc/apt/apt.conf.d/20apt-esm-hook.conf.bak && \
sudo touch /etc/apt/apt.conf.d/20apt-esm-hook.conf

Mechanism: This approach renames the original hook file, preserving it as a backup (.bak), and then creates a new, empty file with the original name. APT will find this empty file, which contains no instructions to execute, thus suppressing the message.

This method is often favored as it cleanly prevents the hook’s execution without generating APT notices about irregular files, which can occur with other techniques like symlinking.

Technique B: Comment Out File Internals

Command:

sudo sed -i'' -e 's/^\(\s\+\)\([^#]\)/\1# /' /etc/apt/apt.conf.d/20apt-esm-hook.conf

Mechanism: This command utilizes the stream editor sed to modify the file in-place. It prepends a comment character (#) to the beginning of all lines that are not already comments and contain non-whitespace characters. This effectively deactivates all operative commands within the script without deleting or renaming the file.

Technique C: Create a Symbolic Link to /dev/null

Command:

sudo ln -s -f /dev/null /etc/apt/apt.conf.d/20apt-esm-hook.conf

Mechanism: This technique creates a symbolic link (symlink) at the location of the hook file, pointing it to /dev/null. The /dev/null device is a special file that discards all data written to it and provides no data when read. Consequently, when APT attempts to process the hook file, it effectively reads nothing, preventing message display.

Be aware that this method may cause APT to issue a notice, such as: N: Ignoring '20apt-esm-hook.conf' in directory '/etc/apt/apt.conf.d/' as it is not a regular file. The functionality of APT itself remains unaffected.

Technique D: Implement Automated Re-deletion of the Hook File

Commands:

sudo rm -f /etc/apt/apt.conf.d/20apt-esm-hook.conf
echo 'APT::Update::Post-Invoke-Success {"rm -f /etc/apt/apt.conf.d/20apt-esm-hook.conf";}' | \
sudo tee /etc/apt/apt.conf.d/99wupdate-notifier > /dev/null

Mechanism: This is a two-step process. First, the existing 20apt-esm-hook.conf file is forcefully removed. Second, a new APT configuration file, 99wupdate-notifier, is created. This new file defines an APT hook that executes a command (rm -f /etc/apt/apt.conf.d/20apt-esm-hook.conf) after every successful apt update operation. This ensures that if the system attempts to recreate the 20apt-esm-hook.conf file, it will be automatically deleted again, providing a persistent solution.

Decision flowchart for the Ubunto Ads issue

Decision flowchart – (SVG image may be scalable when clicked)

Read: How to fix Bluetooth connection problems on Ubuntu 22.04

Method 2: Using the pro Command Configuration

Ubuntu provides the pro command-line tool to manage Ubuntu Pro services. This tool includes a configuration option to disable APT-related news or messages:

sudo pro config set apt_news=false

This is an officially supported way to opt-out. However, it’s worth noting that this setting might not suppress all types of messages fromubuntu-advantage-tools, particularly if new notification types are introduced in the future (e.g., messages about ‘esm-apps’).

Method 3: Removing ubuntu-advantage-tools (Advanced)

For those who do not require any services provided by ubuntu-advantage-tools, removing the package entirely is an option. This should be approached with caution due to potential dependencies.

Sub-method 3.1: Direct Purging

The package and its related client can be purged using APT:

sudo apt-get --assume-yes --purge remove ubuntu-advantage-tools ubuntu-pro-client

Considerations:

  • This command can sometimes lead to the removal of other packages, including meta-packages like ubuntu-desktop or essential components if they depend on ubuntu-advantage-tools. While meta-packages often can be removed without immediate loss of desktop functionality, it’s crucial to review the list of packages to be removed before proceeding.
  • Certain packages (e.g., ttf-mscorefonts-installer, via update-notifier-common) might list ubuntu-advantage-tools as a dependency, potentially leading to its reinstallation if those dependent packages are installed or updated.

Sub-method 3.2: Replacement with a Dummy Package

A more sophisticated approach involves replacing ubuntu-advantage-tools with a custom-built empty (or “dummy”) package. This dummy package declares that it Provides, Breaks, and Conflicts with ubuntu-advantage-tools. This satisfies the dependency system while ensuring the actual ubuntu-advantage-tools package cannot be installed.

Steps typically involve:

  1. Download a pre-built dummy .deb package. One such package (check for the latest versions or sources) may be named similar to fake-ubuntu-advantage-tools.deb.
  2. (Optional) Verify the package metadata to understand its behavior:
    dpkg -I #path/to/your/downloaded/fake-ubuntu-advantage-tools.deb

    This will show control information, typically detailing how it conflicts with and provides the original package:

    
     Package: fake-ubuntu-advantage-tools 
     Version: 0.1
     Architecture: all
     Conflicts: ubuntu-advantage-tools
     Breaks: ubuntu-advantage-tools
     Provides: ubuntu-advantage-tools
     Description: Ban ubuntu-advantage-tools while satisfying ubuntu-minimal dependency
     ...
                    
  3. (Optional) Verify that the package contents are indeed minimal (empty):
    dpkg -c #path/to/your/downloaded/fake-ubuntu-advantage-tools.deb

    Output should confirm an empty structure, usually just a root directory entry.

  4. Install the dummy package. Navigate to the directory containing the downloaded .deb file and run:
    sudo apt install ./#your-downloaded-fake-ubuntu-advantage-tools.deb

    APT will then offer to remove the conflicting ubuntu-advantage-tools and install the fake one.

Ensure the dummy package version is appropriate and addresses known issues, such as conflicts with essential desktop components. Updated versions of such dummy packages aim to resolve these conflicts.

Read: How to Fix ‘Cannot Refresh snap-store: Has Running Apps’ Error on Ubuntu

Method 4: Removing Message Template Files (Potentially Temporary)

The actual text of the messages is often stored in template files. Removing these templates can prevent the messages from being displayed:

sudo rm /var/lib/ubuntu-advantage/messages/*.tmpl

Consideration: These template files might be regenerated by ubuntu-advantage-tools itself or during system updates (e.g., by scripts like /usr/lib/python3/dist-packages/uaclient/messages.py). Thus, this solution might only be temporary unless the underlying generation mechanism is also disabled.

Method 5: Addressing MOTD Announcements and Disabling the Service (Related Issue)

While the primary concern is often messages during APT operations, similar promotional messages can appear in the “Message Of The Day” (MOTD) upon login. Some components of ubuntu-advantage-tools contribute to these as well. The following commands target MOTD announcements and the related service:

sudo rm -f /etc/update-motd.d/88-esm-announce
sudo systemctl disable ubuntu-advantage

Disabling the ubuntu-advantage service might have a broader effect in reducing various notifications from this suite, potentially including those tied to APT if the service is involved in their management or restoration.

Verifying the Changes

After applying any of these solutions, the most straightforward way to verify success is to run an APT operation:

sudo apt update

Observe the terminal output. If the Ubuntu Pro promotional messages are no longer displayed, the chosen method has been effective.

Important Considerations

  • Persistence: Some fixes, especially file deletions or modifications, might be undone by updates to ubuntu-advantage-tools or other system packages. Solutions involving dummy packages or APT hooks for re-deletion are generally more resilient.
  • System Impact: When removing packages like ubuntu-advantage-tools, carefully review the list of packages that APT proposes to remove to avoid unintentionally uninstalling critical system components.
  • GUI vs. CLI: Some solutions primarily target command-line APT behavior. Graphical software updaters might have their own mechanisms for displaying similar information, which may not be affected by all these methods. The file renaming approach (Method 1, Technique A) for 20apt-esm-hook.conf has been reported to address command-line messages but not always those in GUI updaters.

Conclusion

Unwanted Ubuntu Pro notifications appearing during apt operations stem from the ubuntu-advantage-tools package and its integration with the system’s package management. Fortunately, a variety of methods exist to control this behavior.

 

 

Akil Sharma

Akil is a dedicated Cybersecurity Analyst with a strong focus on both offensive and defensive security techniques across Linux and Windows platforms. He delves into topics like vulnerability assessment, penetration testing methodologies, malware analysis, incident response, and implementing security frameworks. Akil is committed to educating readers on the latest threats and sharing actionable strategies for hardening systems and protecting data.