149

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?

7
  • 2
    Cannot be seen on my 22.04 system but it certainly looks like one of the scripts in /etc/update-motd.d could be causing this annoyance. General info here: ubuntu.com/legal/motd, looks easy enough to disable: "/etc/default/motd-news has an ENABLED=1 setting that if set to 0 will turn off this functionality."
    – andrew.46
    Oct 9, 2022 at 8:44
  • 4
    Likely of interest - Ubuntu Pro APT integration is a bit much so the problem should reduce with time (at the very least) ; though I also noticed it as occurring on Kubuntu or a desktop flavor too
    – guiverc
    Oct 10, 2022 at 2:28
  • 4
    Consider evaluating other DEB based distros? Debian, Devuan, etc all exist and work. Voting with your feet might be a reasonable action. You're not stuck with one distro.
    – Criggie
    Oct 11, 2022 at 20:48
  • 2
    There is a bug report on this. bugs.launchpad.net/ubuntu/+source/ubuntu-advantage-tools/+bug/… Oct 13, 2022 at 13:26
  • 2
    @Rinzwind It is an advertisement without any doubt. Plugging a commercial product with standard phrasing shown automatically to all people using it IS an ad. Mar 7, 2023 at 8:36

8 Answers 8

101

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
7
  • 16
    This seems like the most complete and correct answer to me. Although when using a symbolic link to /dev/null I get an notice about it not being a 'regular file'. That third option for the win. Thank you. Oct 19, 2022 at 11:37
  • This is the first thing I've tried that really lasted across an apt update and reboot. Oct 19, 2022 at 18:00
  • 1
    I tried the 3rd option (rename the file etc.) and unfortunately it didn't work for me. Ubunut 22.04 LTS server. Feb 11, 2023 at 10:09
  • 1
    The third option worked great for me on Ubuntu 20.04.5 LTS desktop. Thanks.
    – Johan
    Feb 16, 2023 at 8:27
  • First option results in N: Ignoring '20apt-esm-hook.conf' in directory '/etc/apt/apt.conf.d/' as it is not a regular file showing app on using apt Dec 15, 2023 at 19:09
32

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
5
  • 2
    I want to point out a disadvantage to this method -- Ubuntu may add more sources of spam to Ubuntu Advantage in future, and the user would have to set more and more undocumented flags for each spam type as they're added. However, for users who need Advantage installed, your solution seems like their only option. As such, I've added this method to the overall guide on removing spam from Ubuntu as one method and I thank you for sharing this secret flag with us.
    – Skye
    Apr 4, 2023 at 22:59
  • 17
    This does not remove the Get more security updates through Ubuntu Pro with 'esm-apps' enabled message.
    – sds
    Apr 19, 2023 at 21:53
  • 1
    did not work for me
    – teknopaul
    Feb 21 at 9:11
  • I wonder where it is possible to tell Ubuntu developers how extremely annoying this is. Stuff like this makes me want to switch to a different distro
    – jpp1
    Apr 7 at 7:45
  • @jpp1 In my case, it did. Apr 11 at 3:24
25

Remove message of the day file and disable Ubuntu Advantage:

sudo rm /etc/update-motd.d/88-esm-announce
sudo systemctl disable ubuntu-advantage
2
  • 7
    This isn't an answer to the question: you got the wrong advert. The question is about a different advert.
    – wizzwizz4
    Oct 11, 2022 at 22:20
  • @wizzwizz4 this worked for me
    – MacroMan
    Feb 27, 2023 at 9:18
21

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.

6
  • This workaround does not work anymore. Feb 18, 2023 at 14:33
  • 1
    @ErkinAlpGüney care to elaborate? It works fine for me. Feb 19, 2023 at 20:44
  • I am still using this method myself on 22.10
    – Skye
    Feb 20, 2023 at 9:49
  • Note - there was a request that changed the links to the waybackmachine internet archive. I have rejected this edit request as the archived version of that page does not allow the user to download the package, thus making the download link not useful.
    – Skye
    Feb 23, 2023 at 0:31
  • 3
    @wvengen gamemanj found a new workaround for this, I updated guide with a link to updated package
    – Skye
    Mar 18, 2023 at 0:20
13

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
9
  • 3
    Upon a restart, the message comes back again, so this "fix" is only temporary. Is there anyway to make it more permanent perhaps? Oct 9, 2022 at 23:05
  • @Scotty /var/lib is for "Variable state information for programs", so there's probably a separate config file elsewhere, maybe in /etc. Cf. How to disable the advertisements when sshing into an Ubuntu machine
    – wjandrea
    Oct 10, 2022 at 0:01
  • Remove those files via /etc/rc.local?
    – Waxrat
    Oct 10, 2022 at 16:58
  • FWIW, I rebooted my Ubuntu host and those files did not reappear.
    – Waxrat
    Oct 10, 2022 at 17:14
  • 3
    The messages did eventually come back. Apparently created by /usr/lib/python3/dist-packages/uaclient/messages.py. Search for SS_LEARN_MORE and change it to SS_LEARN_MORE = ""
    – Waxrat
    Oct 11, 2022 at 11:05
9

I would just do:

apt-get  --assume-yes  --purge  remove  ubuntu-advantage-tools
4
  • 3
    This appears to be the best answer. When you remove this package, it also removes OTHER branding packages that aren't needed - "ubuntu-advantage-tools* ubuntu-minimal* ubuntu-server* update-manager-core* update-notifier-common*". You can add them back (if needed) without bringing in the tools package.
    – xrobau
    Oct 21, 2022 at 2:09
  • 3
    Unfortunately, if you want to install the package ttf-mscorefonts-installer it will pull update-notifier-common and ultimately the ubuntu-advantage-tools. In conclusion there is no way to get rid of the ads with deleting ttf-mscorefonts-installer altogether. Oct 25, 2022 at 16:32
  • 1
    Why have any other answers been upvoted?! This is the least hacky way to sort out the problem +1
    – moo
    Jan 17 at 19:49
  • 1
    @moo Thank you. I have tried several methods on > 100 Ubuntu servers and this gave the best results. Jan 19 at 13:03
6

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.

3
  • 6
    I don’t like it but I don’t think it’s illegal in the U.K. (though I’m no lawyer). It’s not direct marketing as it’s a feature of the system that produces the messages. It’s not targeted; direct marketing (prohibited without consent) would be things like keeping a database of users and emailing them. This is different, and you can opt out by stopping using the os - unlike receiving unsolicited mail. But I agree - complain as it’s not in the spirit of Ubuntu.
    – Will
    Oct 14, 2022 at 19:10
  • 1
    «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.» <-- I think it's probably not a crime for Ubuntu to inform its existing users that they can get extra support for free that you previously accepted having to pay for. Feb 17, 2023 at 2:46
  • 2
    It’s the same message for everyone; this has nothing to do with data privacy.
    – bfontaine
    Apr 4, 2023 at 13:14
1

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .