Linux Notepad

Create a custom Message of the Day (MOTD) banner (Debian/Ubuntu)

This guide explains how to create a custom MOTD (Message of the Day) banner for your system.
The custom MOTD banner will be displayed to users upon login, locally or via SSH, providing short system information.

This setup was tested on Debian 12 (Bookworm) and Ubuntu, but it should work on other Debian-based systems.

Dependencies installation

sudo apt install figlet lsb-release -y

figlet is a program that generates text banners in various fonts, and lsb-release provides information about the Linux distribution.

Remove existing MOTD files

sudo rm /etc/update-motd.d/*
sudo truncate -s 0 /etc/motd

The /etc/update-motd.d/ folder contains scripts that generate the MOTD dynamically.
The /etc/motd file is the static (generated) MOTD file that is displayed to users.

Create a custom MOTD script

1. Create the header script:

sudo touch /etc/update-motd.d/00-header && sudo chmod +x /etc/update-motd.d/00-header && sudo nano /etc/update-motd.d/00-header

Add the following content to the file:

#!/bin/sh
[ -r /etc/lsb-release ] && . /etc/lsb-release

if [ -z "$DISTRIB_DESCRIPTION" ] && [ -x /usr/bin/lsb_release ]; then
    # Fall back to using the very slow lsb_release utility
    DISTRIB_DESCRIPTION="$(lsb_release -s -i) $(cat /etc/debian_version) ($(lsb_release -s -c))"
fi

HOSTNAME=$(echo $(hostname) | tr "-" " ")
for bit in $HOSTNAME
do
    figlet $bit
done
printf "\n"

printf "Welcome to %s (%s).\n" "$DISTRIB_DESCRIPTION" "$(uname -r)"
printf "\n"

Note: If the hostname contains hyphens, they will be replaced with new lines in the output.

2. Create the system information script:

sudo touch /etc/update-motd.d/10-sysinfo && sudo chmod +x /etc/update-motd.d/10-sysinfo && sudo nano /etc/update-motd.d/10-sysinfo

Add the following content to the file:

#!/bin/sh
date=`date`
load=`cat /proc/loadavg | awk '{print $1}'`
root_usage=`df -h / | awk '/\// {print $(NF-1)}'`
memory_usage=`free -m | awk '/Mem/ { printf("%3.1f%%", $3/$2*100) }'`
swap_usage=`free -m | awk '/Swap/ { printf("%3.1f%%", $3/$2*100) }'`
users=`users | wc -w`
ip_address=$(hostname -I | cut -d' ' -f1)  # Get the first IP address

echo "System information as of: $date"
echo
printf "System load:\t%s\tMemory usage:\t%s\n" $load $memory_usage
printf "Usage on /:\t%s\tSwap usage:\t%s\n" $root_usage $swap_usage
printf "Local users:\t%s\n" $users
printf "Local IP address:\t%s\n" $ip_address
echo

Test the custom MOTD

To test the custom MOTD, you can either log out and log back in or use the following command:

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

Example output:

 _     _                    _   _       _                       _
| |   (_)_ __  _   ___  __ | \ | | ___ | |_ ___ _ __   __ _  __| |
| |   | | '_ \| | | \ \/ / |  \| |/ _ \| __/ _ \ '_ \ / _` |/ _` |
| |___| | | | | |_| |>  <  | |\  | (_) | ||  __/ |_) | (_| | (_| |
|_____|_|_| |_|\__,_/_/\_\ |_| \_|\___/ \__\___| .__/ \__,_|\__,_|
                                               |_|

Welcome to Debian 12.10 (bookworm) (6.1.0-32-amd64).

System information as of: Tue May 27 03:36:44 PM UTC 2025

System load:    0.12    Memory usage:   8.7%
Usage on /:     34%     Swap usage:     7.0%
Local users:    5
Local IP address:       123.123.123.123

Resources

Back to homepage