The message of the day (MOTD) is the text your server prints right after you log in over SSH. On Ubuntu it is built from small scripts, and by default it includes news, links and upgrade notices you may not want. This guide shows how to replace the static text, remove the parts you do not need and add a short status line with disk use and load.
Before you start
- A Linux VPS with Ubuntu 22.04 or 24.04, or Debian 12.
- An SSH session as root or as a user with sudo. If you do not have one yet, see Create a sudo user on Linux.
- A second SSH window kept open while you work, so a mistake never leaves you without a shell.
How the MOTD is built
Two pieces make up what you see at login:
/etc/motd: a plain text file printed as it is. On Debian 12 it holds the standard licence notice. On Ubuntu it is often missing or empty./etc/update-motd.d/: a folder of executable scripts. At login, the PAM modulepam_motdruns every executable script in this folder in name order and shows the combined output. Ubuntu ships many of these; Debian ships only10-uname.
List the scripts on your server:
ls -l /etc/update-motd.d/On Ubuntu you will usually see names such as 00-header, 10-help-text, 50-motd-news, 50-landscape-sysinfo and 90-updates-available. The number sets the order.
Change the static message
To print your own text, for example a warning for other admins, edit /etc/motd:
sudo nano /etc/motdReplace the contents with something short and useful:
web01.example.com - production web server
Changes must be logged in the team ticket before you restart services.Save and log in again in a new window to see it. Keep the message brief; long banners get skipped.
Turn off the parts you do not want
The safe way to silence a script is to remove its execute bit. The file stays in place, so a package update can still replace it cleanly, and you can turn it back on later.
sudo chmod -x /etc/update-motd.d/10-help-textUbuntu news and ads
The 50-motd-news script fetches short news items from Canonical. Switch it off in its config file:
sudo sed -i 's/^ENABLED=1/ENABLED=0/' /etc/default/motd-newsYou can also remove its execute bit as above. On Ubuntu releases that show Ubuntu Pro or ESM adverts in the update notice, those lines come from the 90-updates-available and related scripts. Check which script prints a line by running it on its own:
sudo run-parts --test /etc/update-motd.d/
sudo /etc/update-motd.d/90-updates-availablerun-parts --test only lists the scripts that would run, so it is a quick way to confirm your changes.
Tip: Keep the updates notice if you can. Seeing "X updates can be applied" at login is a useful nudge to patch the server.
Add a status line with disk and load
Create your own script. A higher number puts it near the end of the message:
sudo nano /etc/update-motd.d/60-server-statusPaste this:
#!/bin/sh
echo
echo "Host: $(hostname -f 2>/dev/null || hostname)"
echo "Uptime: $(uptime -p)"
echo "Load: $(cut -d' ' -f1-3 /proc/loadavg)"
echo "Disk /: $(df -h / | awk 'NR==2 {print $3 " used of " $2 " (" $5 ")"}')"
echo "Memory: $(free -h | awk '/^Mem:/ {print $3 " used of " $2}')"Make it executable and test it directly:
sudo chmod +x /etc/update-motd.d/60-server-status
/etc/update-motd.d/60-server-statusExpected output looks like this:
Host: web01.example.com
Uptime: up 3 days, 4 hours
Load: 0.08 0.05 0.01
Disk /: 6.1G used of 40G (16%)
Memory: 512Mi used of 3.8GiKeep scripts fast. Every login waits for them to finish, so avoid network calls or slow commands such as a full du scan.
Check SSH settings
OpenSSH has its own PrintMotd option. On Ubuntu and Debian it is set to no in /etc/ssh/sshd_config, because PAM already prints the MOTD. Leaving it at no avoids seeing the message twice. Check the active value with:
sudo sshd -T | grep -i printmotdIf you changed this setting and now see the message twice, set PrintMotd no again, test the config with sudo sshd -t, then reload SSH:
sudo systemctl reload sshWarning: Always run sudo sshd -t before reloading SSH. A typo in sshd_config can stop new logins. Keep your existing session open until a fresh login works.
Check it works
- Open a new SSH session to the server, for example
ssh deploy@203.0.113.10. - Confirm your static text and status block appear, and the parts you disabled are gone.
- Run
sudo run-parts --test /etc/update-motd.d/to see exactly which scripts are active.
Troubleshooting
- Your script does not appear: it is probably not executable or its name contains a dot.
run-partsskips names with dots, so use60-server-status, not60-server-status.sh. - The message shows twice: both PAM and SSH are printing it. Set
PrintMotd noinsshd_configand reload SSH. - Login is slow: one of the scripts is slow. Time each one with
time sudo /etc/update-motd.d/<name>and disable or simplify the slow one. - Nothing shows with a
.hushloginfile: a file named.hushloginin your home folder hides the MOTD for that user. Delete it withrm ~/.hushlogin. - Changes vanished after an update: you edited a packaged script. Disable packaged scripts with
chmod -xand put your own text in a new file instead.
Next steps
- Get alerts when someone logs in: Send SSH login alerts.
- Keep an eye on resources beyond the login screen: Monitor Linux server resources.
- Set up regular patching: Automatic security updates on Linux.
