107

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?

BeastOfCaerbannog
  • 12,964
  • 10
  • 49
  • 77
Scotty_Trees
  • 1,272
  • 2
  • 3
  • 8
  • 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: https://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 09 '22 at 08:44
  • @JohnC I've not seen it either (inc. on *jammy* [22.04] & *kinetic* [what will be 22.10]) but I'm largely a desktop user, and it depends I gather what ISO/media was used to install the system, plus what packages have been added as to whether or not you'll see it. Only a portion of users see it (*sorry I've not explored the code, nor taken much notice of the discussions over prior weeks-months on those changes; it's of no interest to me; there have been recent announcements on it*) – guiverc Oct 10 '22 at 01:38
  • 4
    Likely of interest - [Ubuntu Pro APT integration is a bit much](https://bugs.launchpad.net/ubuntu/+source/ubuntu-advantage-tools/+bug/1992026) 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 '22 at 02:28
  • 3
    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 '22 at 20:48
  • 2
    There is a bug report on this. https://bugs.launchpad.net/ubuntu/+source/ubuntu-advantage-tools/+bug/1992026 – Mark Fraser Oct 13 '22 at 13:26
  • 1
    it is not an "advertisment". it is a "plug". Distinct difference between the 2. – Rinzwind Oct 14 '22 at 06:28
  • 1
    @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. – reducing activity Mar 07 '23 at 08:36

7 Answers7

62

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
John Weldon
  • 158
  • 5
nb52er
  • 946
  • 2
  • 7
  • 10
    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. – Luis Flores III Oct 19 '22 at 11:37
  • This is the first thing I've tried that really lasted across an `apt update` and reboot. – Glen Whitney Oct 19 '22 at 18:00
  • I tried the 3rd option (rename the file etc.) and unfortunately it didn't work for me. Ubunut 22.04 LTS server. – András Aszódi Feb 11 '23 at 10:09
  • The third option worked great for me on Ubuntu 20.04.5 LTS desktop. Thanks. – Johan Feb 16 '23 at 08:27
21

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.
  • 163
  • 1
  • 1
  • 9
16

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

Source

Gaia
  • 625
  • 2
  • 9
  • 24
  • 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](https://github.com/Skyedra/UnspamifyUbuntu) as one method and I thank you for sharing this secret flag with us. – Skye Apr 04 '23 at 22:59
  • 4
    This does not remove the `Get more security updates through Ubuntu Pro with 'esm-apps' enabled` message. – sds Apr 19 '23 at 21:53
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
BeastOfCaerbannog
  • 12,964
  • 10
  • 49
  • 77
Waxrat
  • 265
  • 1
  • 5
  • 3
    Upon a restart, the message comes back again, so this "fix" is only temporary. Is there anyway to make it more permanent perhaps? – Scotty_Trees Oct 09 '22 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](/q/1083504/301745) – wjandrea Oct 10 '22 at 00:01
  • Remove those files via /etc/rc.local? – Waxrat Oct 10 '22 at 16:58
  • FWIW, I rebooted my Ubuntu host and those files did not reappear. – Waxrat Oct 10 '22 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 '22 at 11:05
  • Do the same for `TRY_UBUNTU_PRO_BETA` – Waxrat Oct 11 '22 at 16:10
  • So stick the command in crontab ;-) – Rinzwind Oct 14 '22 at 06:29
  • @WaxratI I wonder if the message appeared after upgrading a certain package though, such as `ubuntu-advantage-tools` itself. – Lethargos Oct 21 '22 at 12:53
  • Likely an upgrade of that uaclient/messages.py caused the ad to start appearing. After I edited messages.py as described above, the ad stopped appearing – Waxrat Oct 22 '22 at 19:04
12

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
  1. (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 ./
  1. 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.
  1. 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.

Skye
  • 139
  • 6
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Nov 01 '22 at 11:56
  • This workaround does not work anymore. – Erkin Alp Güney Feb 18 '23 at 14:33
  • 1
    @ErkinAlpGüney care to elaborate? It works fine for me. – Greg Chabala Feb 19 '23 at 20:44
  • I am still using this method myself on 22.10 – Skye Feb 20 '23 at 09: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 '23 at 00:31
  • It works, but also uninstalls e.g. `gnome-software` and `vanilla-gnome-desktop`, among others. Trying to install them, somehow pulls back in `ubuntu-advantage-tools`. – wvengen Mar 16 '23 at 08:43
  • 2
    @wvengen gamemanj found a new workaround for this, I updated guide with a link to updated package – Skye Mar 18 '23 at 00:20
7

I would just do:

apt-get  --assume-yes  --purge  remove  ubuntu-advantage-tools
  • 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 '22 at 02:09
  • 2
    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. – Cyril Chaboisseau Oct 25 '22 at 16:32
5

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.

BFG
  • 79
  • 1
  • 5
    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 '22 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. – Jo-Erlend Schinstad Feb 17 '23 at 02:46
  • 1
    It’s the same message for everyone; this has nothing to do with data privacy. – bfontaine Apr 04 '23 at 13:14