Innovate | Connect | Transform
ContactService statusUSD $

GICT knowledge base

MOTD Explained: The Message of the Day and How to Manage it in Linux

Published

Linux Administration
MOTD Explained: The Message of the Day and How to Manage it in Linux

You SSH into a server and see something like this before the shell prompt:

Welcome to Ubuntu 24.04.1 LTS (GNU/Linux 6.8.0 x86_64)

System information as of Wed Jul  8 22:00:01 UTC 2026
  System load: 0.24              Processes:             527
  Usage of /:  75.4% of 39.12GB   Users logged in:       0
  Memory /:  85% used           swap memory:       0.0%
  Cache /:  624 MB              swap in/out:       0 B

4 packages can be updated.
0 updates are security updates.

That is the MOTD, the Message of the Day. It is generated dynamically at every SSH login. This article shows what produces it, how to change it, and how to add your own information.

How MOTD Works on Ubuntu

Ubuntu uses two MOTD systems. The static /etc/motd is a plain text file that never changes unless you edit it manually. The dynamic MOTD is generated at login from scripts in /etc/update-motd.d/:

ls -la /etc/update-motd.d/

Output on this VPS:

-rwxr-xr-x  1 root root  1220 Apr 22  2024 00-header
-rwxr-xr-x  1 root root  1151 Apr 22  2024 10-help-text
-rwxr-xr-x  1 root root  5023 Apr 22  2024 50-motd-news
-rwxr-xr-x  1 root root  218 Aug  5  2025 90-updates-available
-rwxr-xr-x  1 root root  296 Aug  5  2025 91-contract-ua-esm-status
-rwxr-xr-x  root  558 Jul 25  2025 91-release-upgrade
-rwxr-xr-x  1 root root  165 Feb 12  2024 92-unattended-upgrades
-rwxr-xr-x  1 root root  379 Aug  5  2025 95-hwe-eol
-rwxr-xr-x  1 root root  111 Aug  5  2025 97-overlayroot
-rwxr-xr-x  1 root root  142 Aug  5  2025 98-fsck-at-reboot
-rwxr-xr-xr-x  1 root root  144 Aug  5  2025 98-reboot-required

The files run in alphabetical order. 00-header runs first and prints the hostname, kernel, and OS version. 90-updates-available runs last and prints the package update count.

PAM connects this to SSH. In /etc/pam.d/sshd, this line runs the MOTD generation:

session optional pam_motd.so motd=/run/motd.dynamic

The dynamic MOTD is written to /run/motd.dynamic at login. PAM reads and displays it. The noupdate option on the second motd line prevents a second MOTD from being printed.

Disable the Default MOTD

To disable individual scripts, remove the executable bit:

chmod -x /etc/update-motd.d/50-motd-news
chmod -x /etc/update-motd.d/91-release-upgrade

Removing execute permission stops the script from running without deleting it. The next SSH login will not show those sections.

To disable the entire dynamic MOTD, comment out the PAM line:

sed -i 's/session optional pam_motd.so/#session optional pam_motd.so/' /etc/pam.d/sshd

Add Your Own MOTD Section

Create a new script in /etc/update-motd.d/:

sudo tee /etc/update-motd.d/50-disk-space > /dev/null << 'EOF' #!/bin/sh echo " Disk usage:" df -h / /home 2>/dev/null | awk 'NR==2 {printf "  /: %s used, %s available\n", $5, $4}'
EOF
sudo chmod +x /etc/update-motd.d/50-disk-space

The script name prefix controls run order. Numbers 00-99 determine when it runs. The next SSH login shows the disk usage section. Run it manually to test:

sudo /etc/update-motd.d/50-disk-space

Edit the Static MOTD

The static /etc/motd is displayed alongside the dynamic one. Edit it directly:

sudo vi /etc/motd

Some administrators prefer a fully static MOTD for simplicity. To use only the static version, set the MOTD path explicitly and disable dynamic generation:

# Disable dynamic MOTD
sed -i 's/motd=\/run\/motd.dynamic/motd=\/etc\/motd/' /etc/pam.d/sshd

This replaces the dynamic /run/motd.dynamic path with the static /etc/motd file. After editing /etc/motd, the changes appear at every login without regenerating anything.

Force MOTD Regeneration Without Logging In

The run-parts command runs all scripts in a directory:

sudo run-parts /etc/update-motd.d/ | sudo tee /run/motd.dynamic

This regenerates the dynamic MOTD and writes it to /run/motd.dynamic. Useful after installing packages or making changes that affect the MOTD without requiring a new SSH session.

Related guides

Account services are unavailable until the production backend is configured.