How to get rid of ubuntu-advantage-tools without destroying system [duplicate]

Solution 1:

This fine answer works great for 18.04.

It tells you to remove the package which is great because on 18.04 it only removes the additional package ubuntu-minimal.

However, on 20.04 it wants to remove a lot more stuff, namely

  • ttf-mscorefonts-installer
  • ubuntu-release-upgrader-gtk
  • update-manager
  • update-manager-core
  • update-notifier
  • update-notifier-common

because of the following dependency tree:

$ aptitude why ubuntu-advantage-tools
i   ttf-mscorefonts-installer Depends update-notifier-common (>= 0.119ubuntu2)
i A update-notifier-common    Depends update-manager-core (>= 1:17.04.2)      
i A update-manager-core       Depends ubuntu-advantage-tools           

That's unacceptable, so we have to look for another way. And here it is.

  1. Stop and mask the services

    sudo systemctl stop ua-messaging.timer
    sudo systemctl stop ua-messaging.service
    sudo systemctl stop ua-timer.timer
    sudo systemctl mask ua-messaging.timer
    sudo systemctl mask ua-messaging.service
    sudo systemctl mask ua-timer.timer
    
  2. Check that it worked

    systemctl status ua-messaging.service
    systemctl status ua-messaging.timer
    systemctl status ua-timer.timer
    

    You should see a status like this for each

    $ systemctl status ua-messaging.service
    * ua-messaging.service
        Loaded: masked (Reason: Unit ua-messaging.service is masked.)
        Active: inactive (dead)
    $ systemctl status ua-messaging.timer
    * ua-messaging.timer
        Loaded: masked (Reason: Unit ua-messaging.timer is masked.)
        Active: inactive (dead) since Fri 2021-11-12 23:10:16 GMT; 1min 2s ago
       Trigger: n/a
    
    Nov 12 01:09:42 focal systemd[1]: Started Ubuntu Advantage update messaging.
    Nov 12 01:10:16 focal systemd[1]: ua-messaging.timer: Succeeded.
    Nov 12 01:10:16 focal systemd[1]: Stopped Ubuntu Advantage update messaging.
    $ systemctl status ua-timer.timer
    * ua-timer.timer
        Loaded: masked (Reason: Unit ua-timer.timer is masked.)
        Active: inactive (dead)
       Trigger: n/a
    
  3. Remove the APT hook (see this answer for details why)

    sudo rm /etc/apt/apt.conf.d/20apt-esm-hook.conf
    

and after a day or so check /var/log/ubuntu-advantage.log to confirm it is not running any more.