176

Recently, whenever I run apt update/upgrade, I get the following message in the terminal:

Try Ubuntu Pro beta with a free personal subscription on up to 5 machines.
Learn more at https://ubuntu.com/pro

Does anyone know any way to get rid of this?

muru
  • 207,228
Scotty_Trees
  • 1,970
  • 3
  • 5
  • 9

8 Answers8

133

One option is to create a symbolic link for 20apt-esm-hook.conf to /dev/null:

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

Another option is to just comment out the action lines in that file:

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

Or a third option is to just rename that file to a .bak file, and create a zero length file of the same name:

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
nb52er
  • 1,686
38

The apt advert is opt-out, and Canonical's official way to do so is somewhat of a secret. The interface for disabling this is:

sudo pro config set apt_news=false
Pablo Bianchi
  • 17,371
Gaia
  • 977
24

Remove message of the day file and disable Ubuntu Advantage:

sudo rm /etc/update-motd.d/88-esm-announce
sudo systemctl disable ubuntu-advantage
Andrew T.
  • 181
  • 1
  • 2
  • 10
23

To get rid of the spam, uninstall the program generating the spam.

The package that generates this spam is ubuntu-advantage-tools. Unfortunately, removing it is tricky since Ubuntu devs have decided to make this a required system package so they can make more money (yes, that is their official justification).

A clever person named vi0oss came up with a workaround: replace the spammy package with an additional package which Provides, Breaks and Conflicts with ubuntu-advantage-tools. When this fix broke due to Ubuntu devs requiring a later version, gamemanj found a second workaround. All this has been bundled into the latest version linked below.

Guide

  1. Download the fake package here.
  2. (Optional) Verify package with dpkg -I fake-ubuntu-advantage-tools.deb to check the metadata to see how it works:
    new Debian package, version 2.0.
    size 744 bytes: control archive=384 bytes.
        300 bytes,     8 lines      control              
    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
    Maintainer: Vitaly _Vi Shukela
    
  3. (Optional) Verify package with dpkg -c fake-ubuntu-advantage-tools.deb to check it's actually empty:
    drwxr-xr-x root/root         0 2022-10-31 11:58 ./
    
  4. Install the package: apt install ./fake-ubuntu-advantage-tools.deb
    The following packages will be REMOVED:
      ubuntu-advantage-tools
    The following NEW packages will be installed:
      fake-ubuntu-advantage-tools
    0 upgraded, 1 newly installed, 1 to remove and 1 not upgraded.
    
  5. No more ads!

Bonus: I have uploaded a page with additional Ubuntu spam fighting steps on GitHub here to get rid of MOTD spam, etc.

Pablo Bianchi
  • 17,371
Skye
  • 359
14

I would just do:

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

strace says it comes from here:

33812 openat(AT_FDCWD, "/var/lib/ubuntu-advantage/messages/apt-pre-invoke-no-packages-apps.tmpl", O_RDONLY) = 3
33812 read(3, "Try Ubuntu Pro beta with a free "..., 8191) = 111

So:

sudo rm /var/lib/ubuntu-advantage/messages/*.tmpl
Waxrat
  • 263
8

You can also raise a complaint at: https://ubuntu.com/legal/data-privacy/enquiry

The fact there is no easy way to switch off these messages is probably against data protection regulations in many countries.

For instance in the UK, it is illegal to market to any user of a service without asking for prior consent and giving you an opportunity to say no.

6

Deleting

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

worked for me. Adding another apt hook that deletes it if it comes back

echo '
APT::Update::Post-Invoke-Success {"rm -f /etc/apt/apt.conf.d/20apt-esm-hook.conf"}
' > /etc/apt/apt.conf.d/99wupdate-notifier
teknopaul
  • 2,137