HOWTO: Dynamic MOTD for Debian Bullseye GNU/Linux

Questions and discussion about web design, search engine optimisation and hosting
Posts: 311
Joined: 2017-7-5 09:58

Unread post by Santeri » 2021-12-22 21:58

Would you like to have a dynamic message of the day (MOTD) when you log in to your Debian Bullseye?
Image Here are the steps to make that happen. First edit the current motd script:

Code: Select all

sudo nano /etc/update-motd.d/10-uname
and replace the original code with the following code:

Code: Select all

# Replace /etc/update-motd.d/10-uname with this script to get a dynamic MOTD in Debian Bullseye
# After that delete the current motd: sudo rm /etc/motd
# Santeri Kannisto <>
# Public domain, 2021
# Support:
printf "\n%s (%s)\n" "$(lsb_release -s -d)" "$(uname -r)"
printf "System information on %s\n\n" "$(date)"
printf "System Load:\t%s\tIP Address:\t%s\n" "$(cat /proc/loadavg | awk '{print $1}')" "$(hostname -I | awk '{print $1}')"
printf "Memory Usage:\t%s\tSystem Uptime:\t%s\n" "$(free -m | awk '/Mem:/ { total=$2; used=$3 } END { printf("%3.1f%%", used/total*100)}')" "$(uptime | grep -ohe 'up .*' | sed 's/,/\ hours/g' | awk '{ printf $2" "$3 }')"
printf "Disk Usage:\t%s\tProcesses:\t%s\n" "$(df -h / | awk '/\// {print $(NF-1)}')" "$(ps aux | wc -l)"
printf "Swap Usage:\t%s\tLocal Users:\t%s\n\n" "$(free -m | awk '/Swap/ { printf("%3.1f%%", $3/$2*100) }')" "$(users | wc -w)"
Then delete the current motd:

Code: Select all

sudo rm /etc/motd
The next time your login, you will see something like this:

Debian GNU/Linux 11 (bullseye) (5.10.0-9-amd64)
System information on Wed Dec 22 23:45:16 EET 2021

System Load:    0.00    IP Address:
Memory Usage:   11.0%   System Uptime:  1:14 hours
Disk Usage:     16%     Processes:      87
Swap Usage:     0.0%    Local Users:    1

Last login: Wed Dec 22 22:56:09 2021 from

Happy hacking,