A Highland cow on Pupers Hill, in southern Dartmoor, England. Photo by Nilfanion; licensed under CC BY-SA 3.0
A Highland cow on Pupers Hill, in southern Dartmoor, England. Photo by Nilfanion; licensed under CC BY-SA 3.0

So, on Ubuntu, whenever you sign in through SSH you get the MOTD (Message of the Day).

It might look something like this:

Getting rid of news/ads

Now here’s the interesting thing: While on Debian, it simply loads the text contents of /etc/motd whenever you sign in, on Ubuntu that file does not exist. Instead, you get the directory /etc/update-motd.d/ containing a bunch of scripts which generate the MOTD. Please note that it will load the scripts in order, so 00 will come first and 99 will come last.

Let’s start by removing the newsletter/ads. Currently, the news/ads are:

This is actually pulled straight from https://motd.ubuntu.com which, if you open it in a browser, will show that exact text snippet.

The script for pulling it in is /etc/update-motd.d/50-motd-news which in turn loads its config from /etc/default/motd-news which conveniently has the variable ENABLED which we can set from 1 to 0 to disable it. Note there’s another interesting variable: URLS, which allows you to specify another URL to get news from, or even a list of URLs separated by space. So, if you like, you can replace the default news source instead of disabling it. For now, I will disable it.

As soon as I set ENABLED to 0 and sign out and then back in, it’s gone! Yay!

Getting rid of the help text

Whenever you sign in, Ubuntu will also tell you this:

We don’t need this, at least I don’t. We can fix this by modifying /etc/update-motd.d/10-help-text and commenting out those printf lines or replacing them.

I commented out the 3 lines and added this new line at the bottom of the script:

printf " * Wiki: https://wiki.archlinux.org\n"

Considering I wrote my own Ubuntu installer from scratch when I set up this system, I think I can skip the useless Ubuntu documentation (they’re even useless if you used *their* installer).

Finally, I want to make sure nothing modifies my modification: chattr +i /etc/update-motd.d/10-help-text

Adding my own header

I create the file /etc/update-motd.d/01-welcome and make it executable.

touch /etc/update-motd.d/01-welcome && chmod +x /etc/update-motd.d/01-welcome

Now we edit it and add something like:

#!/bin/sh
cat<<EOF

 ▄████████  ▄██████▄   ▄██████▄   ▄█       
███    ███ ███    ███ ███    ███ ███       
███    █▀  ███    ███ ███    ███ ███       
███        ███    ███ ███    ███ ███       
███        ███    ███ ███    ███ ███       
███    █▄  ███    ███ ███    ███ ███       
███    ███ ███    ███ ███    ███ ███▌    ▄ 
████████▀   ▀██████▀   ▀██████▀  █████▄▄██ 
                                 ▀         
EOF

Note: You absolutely have to specify the interpreter on the first line or else it won’t run.

You can generate nice text using either the program figlet or this website.

Adding contact info

Same as above, you might also want to create /etc/update-motd.d/20-contact and adding contact info to be displayed:

#!/bin/sh
cat<<EOF

┌┬┐┌─┐┌─┐┬ ┬  ┌─┐┌─┐┌┐┌┌┬┐┌─┐┌─┐┌┬┐
 │ ├┤ │  ├─┤  │  │ ││││ │ ├─┤│   │
 ┴ └─┘└─┘┴ ┴  └─┘└─┘┘└┘ ┴ ┴ ┴└─┘ ┴

YOUR FULL NAME OR PSEUDONYM
E-Mail: [email protected]
Mobile: +1 206 555 0100
Telegram: @telegram (https://t.me/telegram)
Threema: ECHOECHO (https://threema.id/ECHOECHO)

EOF

QR Codes

Perhaps you want to use qrencode to add some QR code right in the MOTD!

First install:

sudo apt install qrencode

Now let’s say you want a QR Code to send you an SMS:

qrencode -l H -t UTF8 'SMSTO:+12065550100'

Or simply an URL:

qrencode -l H -t UTF8 'https://example.com'

Which will output a QR code you can put straight into your MOTD:

Please note that it should both look and work better in an actual – UTF-8 compatible – terminal than on this website’s code box.

You should also be able to add an email address, or using the TEL: for a phone call, or in theory any protocol your phone understands. I never found an “official” list of protocol/URL/URI types which work for both iOS and Android.

Showing the Hostname

If you install figlet (sudo apt install figlet) you can create the file /etc/update-motd.d/60-hostname with the following contents:

#!/bin/sh
echo "You're connected to:"
figlet "$(hostname -s)"

Which might give you something like:

This can be quite useful to not mix things up in prod! :D

Finally some fun

sudo apt install cowsay fortune
sudo touch /etc/update-motd.d/70-cowsay
sudo chmod +x /etc/update-motd.d/70-cowsay

And add:

#!/bin/sh
/usr/games/fortune -s | /usr/games/cowsay

As you may have noticed we added the full paths because “games” is not in the PATH.

Now when you sign in, you’ll get a lovely greeting like this (every time a different text):

Note: Install the package fortunes for more nonsense! :D

In conclusion

You simply edit or delete the files in /etc/update-motd.d/ or write new ones. I recommend moving them into some backup directory instead of deleting in case you want them later.

Note that while /etc/motd does not exist, you can always preview the dynamically generated motd at /run/motd.dynamic.

I run this blog in my spare time, if I helped you out, consider donating a cup of coffee!