Linux VPS

Customise the login message (MOTD) on Ubuntu and Debian

Change the message you see when you log in over SSH. Edit /etc/motd, trim or add update-motd.d scripts, switch off Ubuntu news and show disk and load at a glance.

IntermediateLinux server5 min read

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 module pam_motd runs every executable script in this folder in name order and shows the combined output. Ubuntu ships many of these; Debian ships only 10-uname.

List the scripts on your server:

Bash
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:

Bash
sudo nano /etc/motd

Replace 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.

Bash
sudo chmod -x /etc/update-motd.d/10-help-text

Ubuntu news and ads

The 50-motd-news script fetches short news items from Canonical. Switch it off in its config file:

Bash
sudo sed -i 's/^ENABLED=1/ENABLED=0/' /etc/default/motd-news

You 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:

Bash
sudo run-parts --test /etc/update-motd.d/
sudo /etc/update-motd.d/90-updates-available

run-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:

Bash
sudo nano /etc/update-motd.d/60-server-status

Paste this:

Bash
#!/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:

Bash
sudo chmod +x /etc/update-motd.d/60-server-status
/etc/update-motd.d/60-server-status

Expected 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.8Gi

Keep 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:

Bash
sudo sshd -T | grep -i printmotd

If you changed this setting and now see the message twice, set PrintMotd no again, test the config with sudo sshd -t, then reload SSH:

Bash
sudo systemctl reload ssh

Warning: 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

  1. Open a new SSH session to the server, for example ssh deploy@203.0.113.10.
  2. Confirm your static text and status block appear, and the parts you disabled are gone.
  3. 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-parts skips names with dots, so use 60-server-status, not 60-server-status.sh.
  • The message shows twice: both PAM and SSH are printing it. Set PrintMotd no in sshd_config and 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 .hushlogin file: a file named .hushlogin in your home folder hides the MOTD for that user. Delete it with rm ~/.hushlogin.
  • Changes vanished after an update: you edited a packaged script. Disable packaged scripts with chmod -x and put your own text in a new file instead.

Next steps

Was this guide helpful?

Still stuck?

Ask MdmHost AI for a quick answer, or open a ticket and our team will take a look. We are here 24/7.