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
Code: Select all
#!/bin/sh
# 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 <santeri.kannisto@webseodesigners.com>
# Public domain, 2021
# Support: https://forum.webseodesigners.com/web-design-seo-and-hosting-f16/howto-dynamic-motd-for-debian-bullseye-gnu-linux-t4558.html
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)"
Code: Select all
sudo rm /etc/motd
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: 172.22.214.86 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 172.22.208.1
Happy hacking,
Santeri