146

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?

Scotty_Trees
  • 1,661
  • 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 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
  • 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 '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
  • 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. – reducing activity Mar 07 '23 at 08:36

8 Answers8

99

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,326
  • 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. – 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
  • 1
    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
  • 1
    The third option worked great for me on Ubuntu 20.04.5 LTS desktop. Thanks. – Johan Feb 16 '23 at 08: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 – reducing activity Dec 15 '23 at 19:09
  • Today all pro updates start to be listed inupdate-manager and I hoped messing up the file as described should help there too, which it does not :-/ – Harald Jan 14 '24 at 11:52
  • Option 3 removed advertisements from command line sudo apt ugrade. However, it did not remove advertisements from GUI Software Updater. – user4955663 Mar 06 '24 at 06:47
31

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
  • 861
  • 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 04 '23 at 22:59
  • 16
    This does not remove the Get more security updates through Ubuntu Pro with 'esm-apps' enabled message. – sds Apr 19 '23 at 21:53
  • 1
    did not work for me – teknopaul Feb 21 '24 at 09:11
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
Andrew T.
  • 173
  • 1
  • 1
  • 9
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
  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
  • 329
  • 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
  • 3
    @wvengen gamemanj found a new workaround for this, I updated guide with a link to updated package – Skye Mar 18 '23 at 00: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
Waxrat
  • 265
9

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
  • 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. – Cyril Chaboisseau Oct 25 '22 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 '24 at 19:49
  • 1
    @moo Thank you. I have tried several methods on > 100 Ubuntu servers and this gave the best results. – Jeroen Vermeulen Jan 19 '24 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.

  • 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 '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
  • 2
    It’s the same message for everyone; this has nothing to do with data privacy. – bfontaine Apr 04 '23 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
teknopaul
  • 2,027
  • 16
  • 18