Advent 2023: MOTD on Ubuntu

I never intended for this Advent 2023 series to be a "Matthew's Bash Tips" series, but evidently, that's where things are going.

Today, I detail how to get the "message of the day" on Ubuntu

Why "message of the day"?

A long-standing tradition on Unix and Linux servers is to emit a "message of the day" when somebody logs in to the server. Often these are setup to only display to the user the first time they login for the day (hence "of the day").

In the old days, this was generally found in /etc/motd, and would be manually updated by systems admins on the machine.

What's changed?

In today's world, the operating system will often have a way to aggregate messages, which simultaneously allows the OS to inject important information: OS and kernel version, uptime, whether or not security patches are available, and more.

On Ubuntu systems, these are pushed to the directory /etc/update-motd.d, and each is a script that can be run to emit information. By using this approach, a script can run commands and determine if anything needs to be communicated, ensuring that you only get up-to-date information.

However... this means you can't just run cat /etc/motd anymore in case you missed it, or your session is still active, or, if you use Linux on the desktop, you want to see it, but are in a graphical shell and never got to see the message.

So, how do you do it?

sudo run-parts /etc/update-motd.d`