gsmaclean.com

Linux console info and motd

When spinning up new Linux VMs I often lose track of IP addresses and hostnames, here’s a quick way to see pertinent info in the console window (e.g. within VirtualBox or VMware Workstation).

Console Info

# /etc/issue
Debian GNU/Linux 12 \n \l
ens33: \4{ens33}  |  \6{ens33}

\4 and \6 show the contained interface addresses, if you just don’t add the interface name, it will report the first non-loopback address – but I like to be explicit. All options are available from ‘man issue’. Note there is a trailing line to separate from the login prompt.

MOTD

Ubuntu specifically has a very noisy MOTD when you login as a user – some of the info is indeed useful, but it’s lost in a sea of trivia.

For Debian systems, you can simply edit the /etc/motd file to clean up or add whatever you’d like, but Ubuntu has a more complex method:

I generally remove the following to clean it up.

  • 91-contract-ua-esm-status
  • 10-help-text
  • 50-motd-news

The ESM / Ubuntu Pro ad requires a little more work to remove as it’s pulled in via the update-notifier used for the useful notifications of available updates. Per https://askubuntu.com/questions/1453749/inhibit-esm-messages-at-login, you can run the follow sed script to remove the offending parts of the script, leaving it otherwise intact.

sudo sed -Ezi.orig -e 's/(def _output_esm_service_status.outstream, have_esm_service, service_type.:\n)/\1    return\n/'   -e 's/(def _output_esm_package_alert.*?\n.*?\n.:\n)/\1    return\n/'   /usr/lib/update-notifier/apt_check.py

This leads to a much more condensed and useful MOTD.