Prose

Nov 22 2024, 8:22 PM

You can turn off the Ubuntu Server ads

Thanks for not making it super hard!

FreeBSD fans may be sad to hear that I recently migrated my custom-built FreeBSD NAS to Ubuntu Server LTS1. This was because:

  1. I now run a Jellyfin media server on my NAS.2
  2. I miss systemd.3

The bad news is that Ubuntu ships with ads on login:

I log into a machine called silicon. Before the shell prompt, the machine shows a bunch of useful info, like OS version, system usage, and current IP addresses, but also links to Ubuntu Pro paid support, an ad for 'secure Kubernetes at the edge', and a different ad for Expanded Security Maintenance for Applications (ESM Apps).
ESM Apps users must sleep so much more soundly at night than I do.

The good news is that it’s easy to turn them off!

All these messages are written out by shell scripts in /etc/update-motd.d/, and you can simply delete the shell scripts that output ads. I deleted 10-help-text, 50-motd-news, 90-updates-available, 91-contract-ua-esm-status. The one that checked for updates seemed useful, but ended with an ad, so I wrote my own replacement for it that didn’t do that.

$ cat 90-updates-available
#!/usr/bin/env bash
echo $(apt list --upgradable 2>/dev/null | grep -v '^Listing' | wc -l) updates available according to current apt db.

Note that good, well-behaved motd scripts should cache their output, but I’m lazy and don’t mind the half second delay my script causes. You can do better, if you feel like it.

And now logging in is much nicer:

I log into silicon again, and this time the machine only displays the useful stuff before the shell prompt.
Finally, I can rest easy not knowing what ESM Apps are.

  1. Now, I much prefer Rocky Linux on most of my servers, but apparently the current ZFS-on-Linux kernel module for RHEL 9 doesn’t support a feature flag that my previous FreeBSD installation enabled. Ubuntu 24.04 had a newer module that worked with my existing ZFS pool. ↩︎

  2. Jellyfin does not officially support FreeBSD, and the unofficial port won’t let me enable hardware acceleration. My poor old pre-Ryzen AMD APU is not up to software encoding as well as I would like. ↩︎

  3. Writing a timer is much easier and more testable than writing a cron job, you can have multiple instances of the same service without much headache, and honestly it’s what I’m familiar with. Oh, and user services are great for running backup scripts without root access. I’m sure writing rc.d scripts is second nature to some folks, but it feels arcane to me. ↩︎

← Back home