Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
FREEDOM251

Freedom251 › Blog › Debian

How to Customize the Message of the Day (MOTD) on Linux

By Freedom251 Team · · 8 min read

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Linux displays the Message of the Day (MOTD) after a successful login through PAM. On a simple system, edit /etc/motd. On Ubuntu and Debian, the visible message is usually generated at each login from executable scripts in /etc/update-motd.d. For SSH, both sshd and the PAM stack must permit the message. Identify which mechanism your distribution uses before changing files.

What the Linux MOTD is and where it comes from

The MOTD is text shown after authentication and before the interactive session starts. The PAM module pam_motd reads one or more message files during the session. It can serve local-console logins and SSH logins, provided the relevant PAM service invokes the module.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Documented search locations include the individual files /etc/motd, /run/motd and /usr/lib/motd, plus the corresponding motd.d directories. Files are displayed in lexicographic order. A file in /etc takes precedence over a same-named file in /run or /usr/lib. Each message is limited to 64 KB.

Location or mechanism Typical role When to use it
/etc/motd One static message file Systems that read a static MOTD
/etc/motd.d Local fragments assembled by pam_motd Adding or overriding individual fragments
/run/motd and /run/motd.d Runtime-generated content Distribution or service-managed messages
/usr/lib/motd and /usr/lib/motd.d Vendor-supplied content Packaged defaults; avoid editing directly
/etc/update-motd.d Executable generators on Ubuntu/Debian Dynamic, per-login output

Run ls -l /etc/motd before editing. If it is a symbolic link to a generated file such as /run/motd.dynamic, writing directly to the link target is not a durable customization.

#1 Best Overall
Sale
TOZO A1 Wireless Earbuds Bluetooth 5.3 Light Weight in Ear Headphones | IPX5 Waterproof,2 Mics for AI Calls,Immersive Premium Sound Bass Headset with Charging Case,32 EQ via App Black
  • [Ultra-Lightweight Ear Buds Designed for Small Ears] Each earbud weighs only 3.7g and features a compact, ergonomic in-ear design made especially for small ears. Secure, low-profile, and comfortable for workouts, all-day wear or overnight sleeping.The ultra-slim profile sits flush in your ear with no hard edges poking or rubbing, so you can even sleep on your side without discomfort.
  • [Immersive Stereo Sound with TOZO OrigX Technology] TOZO OrigX tuning delivers clear vocals, balanced mids, and natural stereo sound for music, podcasts, and videos.
  • [Long Battery Life for Daily Use] Get up to 7 hours of playtime on a single charge, with up to 32 hours total using the charging case—ideal for workdays, commuting, and extended listening sessions.
  • [Bluetooth 5.3 & Stable Connection] Bluetooth 5.3 provides fast pairing, stable wireless performance, and reduced dropouts as you move around home or office.
  • [Deep Bass with Clear Vocals] High-performance drivers produce punchy bass while keeping vocals clean and detailed for everyday listening.

Choose between a static file, fragments, and generated output

The correct method depends on ownership and on whether the text must change with the machine state.

Approach Ownership and persistence Login cost Best for Main risk
Static /etc/motd Local administrator owns one file; changes persist until replaced Negligible A fixed policy, contact, or maintenance notice Generated systems may bypass or overwrite it
/etc/motd.d fragment Local fragment overrides a same-named lower-precedence fragment Negligible Adding one section or silencing a packaged section Filename and precedence mistakes
/etc/update-motd.d script Script output is regenerated at each login Every script runs as root on every login Hostname, kernel, capacity, or status that changes Slow commands, failures, or accidental disclosure

Do not mix methods without checking the active PAM configuration. A static edit can appear to do nothing when the system actually displays generated output, and a dynamic script cannot help if the login service never invokes pam_motd.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Set a static MOTD in /etc/motd

1. Confirm that the file is active

Check whether the path is a regular file or a symbolic link:

ls -l /etc/motd
readlink -f /etc/motd

Also inspect the PAM service used for the login. For local logins, examine /etc/pam.d/login; for SSH, examine /etc/pam.d/sshd. Look for a line that loads pam_motd.so.

2. Replace the message with plain text

Use administrative privileges and preserve a final newline:

Rank #2
Sale
Smart Watch for Men Women Compatible with iPhone Samsung Android Phone 1.69 inch Full Touch Screen IP68 Waterproof Bluetooh Fitness Tracker Heart Rate/Sleep Monitor (Black)
  • 【IP68 Waterproof Multifunctinal Smart Watch】Torjalph fitness activity tracker smart watch is IP68 waterproof technology ,you can wear it when swimming,handwashing,it's rain-proof which means that you perform multiple exercise modes outside without worrying about sweat or rain corroding your fitness smart watch,and this watch equipped with a 230 mAh large capacity battery magnetic charging ,and this sports activity tracker watch can be used 5-7 days If fully charged.
  • 【Larger 1.83'' Full Screen Watch & Multi-dial Selection】1.83 inch full HD color touch screen smart watch for men / women provides excellent 240*284 resolution image quality ,This Bluetooth smart watch offers a better touch experience and remarkable immersion and ,more than 200 watch faces for you to choose from App"Da Fit ", you can change the dial style according to your mood to wear keeping the world on your wrist
  • 【Accurate Activity Tracker Smart Watch 】sports watch activity tracker uses sweat and dust resistant breathable silicone strap, our Fitness Tracker Smart Watch for Android iOS Phones supports 12 sports modes,walking,running,bicycle,swimming,badminton,basketball,football,rope skipping. This bluetooth calls smart watch for men women is lightweight and stylish, bringing more convenient and relaxing sports experience while also providing more protection.
  • 【Your 24 Hour Personal Daily Health Monitor】Fitness watch for women men full touch screen IP67 waterproof bluetooth smartwatch for Android iOS Phones with heart rate blood pressure monitor multifunction Andriod smart watch with steps counter sleep monitor sports fitness watch, monitoring blood oxygen saturation allows you to understand your physical condition in real time to track fitness progress ,to know your health status in time.
  • 【More Functions Bluetooth Call Smart Watch】This fitness activity smart watch full screen for iPhone and Android phones includes a bunch of new features including:The bluetooth smart watch can hang up the phone, receive and display WhatsAPP /Text /Facebook /Twitter /Messenger reminder.Support sedentary reminder, alarm clock, stopwatch, timer,weather information,music control, remote camera control compatible with Android 5.0 and above or iOS 9.0 and above smartphones.
sudo sh -c 'cat > /etc/motd <<"EOF"
Authorized users only.
Maintenance window: Sundays 02:00 UTC.
EOF'

The command replaces the entire file. To append instead, use sudo sh -c 'cat >> /etc/motd <<"EOF" ... EOF', or edit it with an editor such as sudoedit /etc/motd. Keep the content ordinary text; terminal-control sequences can make logs and automated sessions difficult to interpret.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

3. Test the path that users actually use

Start a new console login or a new SSH connection. Existing sessions generally do not replay the MOTD. If the text is absent, continue with the PAM and SSH checks below rather than repeatedly rewriting the file.

Build a dynamic MOTD on Ubuntu or Debian

Ubuntu introduced the update-motd framework, in which scripts are run at login and their standard output is concatenated into /run/motd.dynamic. On a typical Ubuntu installation, /etc/motd points to that generated file. Debian-based systems can differ by release and configuration, so verify the paths on the host.

Create a numbered fragment

Use a numeric prefix such as 90-custom. The filename should have no extension, and it must satisfy the filename rules used by run-parts --lsbsysinit. Make it executable, print to standard output, and end output with a newline:

sudo tee /etc/update-motd.d/90-custom >/dev/null <<'EOF'
#!/bin/sh
echo
echo "Welcome to $(hostname)"
echo "Kernel: $(uname -r)"
EOF
sudo chmod 755 /etc/update-motd.d/90-custom

The shebang selects the interpreter. Avoid writing the result to a separate file: the framework collects what the script writes to standard output. A filename such as 90-custom.sh may be skipped because run-parts excludes names that do not meet its rules.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
New Bee Guitar Cable 10ft Electric Instrument Bass AMP Cord
  • [Low Noise High Fidelity] New bee guitar cord with 22AWG oxygen-free-copper center conductors provides enhanced signal transfer, the PVC insulation material and the high-density stranded copper double shield provide noise rejection for quiet operation
  • [Ideal for Choice] New bee 1/4 straight and right angle metal connectors, ensures a secure connection in any instrument, pedal, or amp jack. L shape great fro on stage guitar stands
  • [Wide Compatible] Suitable for mixer, power amplifier, microphone, effector, decoder, equalizer, electoronic organ, electric guitar, electric bass and other electronic equipments. Widely used in the installation of smart home, karaoke speaker, professional stage audio, etc
  • [Easy Disassemble] Making incidental repairs quick and easy! Very nice, flexible cable
  • [Dont Hesite to Order] 24 hours customer services and professional technology team are standing by

Control order

Fragments are processed in numeric/alphabetical order under run-parts --lsbsysinit. A lower number appears earlier; a higher number can add a closing section. Use distinctive prefixes to avoid collisions with package-provided scripts. Do not edit vendor fragments in place, because package updates can replace them.

Preview the assembled output

Where the framework is present, run:

sudo run-parts --lsbsysinit /etc/update-motd.d

This executes the scripts and prints the text they produce, allowing you to catch syntax errors before opening a new login session. The preview itself does not change which PAM services display the result.

Keep every script fast and predictable

All enabled scripts run as root at login. Avoid network requests, unbounded disk scans, package-manager commands, and commands that can wait for a device or service. If a value is expensive to calculate, generate it periodically and have the MOTD script read a cache. A broken or slow fragment can delay every login, including emergency access.

Override or silence one MOTD fragment

Use /etc/motd.d for local overrides. To suppress a lower-precedence packaged fragment, create a same-named symbolic link in /etc/motd.d that points to /dev/null. For example:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
sudo ln -s /dev/null /etc/motd.d/50-motd-news

The /etc entry wins over a same-named file in /run/motd.d or /usr/lib/motd.d, so the packaged fragment contributes no text. Check the exact filename first with:

Rank #4
BSIMB 15.6" Digital Family Calendar & Chore Chart, No Subscription Fees
  • Digital Family Calendar: BSIMB digital calendar wall touch screen puts an end to your chaotic life. Designed for busy families, the digital calendar keeps you organised and in step with your family. Assign different colours and tasks to each family member to make family scheduling easier and more intuitive.
  • Easy Setup and Auto-Sync: Plug in, connect to WLAN and auto-syn your electric calendar in minutes. Digital wall calendar compatible with Google calendar, iCloud calendar, Outlook calendar, Cozi calendar and Yahoo calendar. Add events directly on the device or through the ecalendar app. Electronic calendar stays current whether you're at work or traveling—no manual updates needed.
  • All-In-One Home Assistant: Smart calendar builds habits and encourage independence with personalised chores. Display daily meal plan to reduce the daily ‘What's for dinner?’ stress. To-do lists keep track of everything you want. Turning chores into valuable achievements with stars and rewards, making life easier and more enjoyable.
  • Manage Anytime Anywhere: BSIMB electronic calendar for family stay connected with the powerful ecalendar app. Access and manage your digital wall calendar anytime, anywhere with free features like stars & rewards, photo screensaver, chore charts, meals plans, to-do lists etc. Electronic planner paid features like Magic Import tailor advanced tools for users with special needs.
  • Stay in Touch with Loved Ones: Share photos or videos from your phone to electronic wall calendar with app, instantly update your life moment, and keep in touch with your family, especially those who are far away; you can also surprise your smart calendar digital wall by sending him a wish card; it's also great for keeping tech-illiterate elders in touch with the youngsters.
find /etc/motd.d /run/motd.d /usr/lib/motd.d -maxdepth 1 -type f -o -type l 2>/dev/null | sort

To restore the packaged message, remove the override link:

sudo rm /etc/motd.d/50-motd-news

Use this technique for a single unwanted section instead of deleting files under /usr/lib or disabling the entire MOTD.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Make SSH and console behavior consistent

An MOTD that appears on the console but not over SSH, or vice versa, usually reflects two separate controls. Debian documents the sshd option PrintMotd, while PAM controls whether pam_motd.so runs for the SSH session.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Check the SSH daemon setting

sudo sshd -T | grep -i printmotd

If the effective value is printmotd no, the SSH daemon will not print the traditional MOTD itself. If you rely on PAM, that setting alone does not prove that the PAM module is enabled; inspect both layers.

Check the PAM stack

grep -n 'pam_motd' /etc/pam.d/login /etc/pam.d/sshd 2>/dev/null

A line containing pam_motd.so determines whether the module runs for that service. A distribution may use different options or include another PAM file, so read surrounding lines and any referenced include files before changing them.

Apply daemon changes safely

If you change sshd_config, validate the syntax before reloading:

sudo sshd -t
sudo systemctl reload ssh

Keep an existing administrative session open while testing a new connection. A configuration error that prevents new SSH sessions can otherwise lock you out.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Distribution boundaries and portability

update-motd is a Debian/Ubuntu-specific patch and is not part of upstream PAM. Other distributions may use only /etc/motd, motd.d, vendor login tooling, or a different PAM arrangement. Never assume that an /etc/update-motd.d directory exists or is executed on a non-Debian system.

On an unfamiliar host, establish the active path in this order:

  1. Identify the distribution and release.
  2. Inspect /etc/motd with ls -l and resolve any link.
  3. List /etc/motd.d, /run/motd.d, and /usr/lib/motd.d if they exist.
  4. Inspect /etc/pam.d/login and /etc/pam.d/sshd for pam_motd.so.
  5. For SSH, inspect the effective PrintMotd value.

Only after these checks should you choose a file or script to modify.

Security, privacy, and maintenance considerations

  • Do not expose secrets. MOTD text is visible to every account that logs in. Avoid tokens, private network addresses, incident details, and command output containing credentials.
  • Remember script privileges. Dynamic fragments execute as root. Use fixed command paths where practical, quote variables, and do not evaluate untrusted text.
  • Keep policy text accurate. An outdated “maintenance” or authorization notice can mislead operators. Store ownership and change history through your normal configuration-management process.
  • Expect package changes. Packaged fragments can be added or renamed during upgrades. Local files in /etc are the appropriate override point.
  • Respect the size limit. Each individual message is limited to 64 KB. Large diagnostic dumps make logins slow and obscure important warnings.

Troubleshoot an MOTD that is missing, duplicated, or stale

Symptom Likely cause Fix
Editing /etc/motd has no effect on Ubuntu /etc/motd links to generated output Check the link target and add or change an executable fragment in /etc/update-motd.d.
Custom dynamic script never appears Not executable, invalid filename, or wrong directory Use a no-extension name, apply chmod 755, and run sudo run-parts --lsbsysinit /etc/update-motd.d.
Text appears on console but not SSH PrintMotd or the SSH PAM stack differs Check sshd -T and /etc/pam.d/sshd separately.
One packaged section will not disappear A lower-precedence copy is still selected Create a same-named /etc/motd.d link to /dev/null; verify the filename exactly.
Login pauses before the shell starts A dynamic fragment performs slow or blocking work Run fragments individually, remove network-dependent commands, and read cached data instead.
Messages appear twice Both sshd printing and PAM printing are enabled Determine which layer should own the MOTD and disable the duplicate path after testing a new session.
Changes vanish after reboot or upgrade The edited file is generated or vendor-owned Move local content to /etc or the local update-motd directory rather than editing /run or /usr/lib.

A practical decision sequence

  1. Need one unchanging notice? Confirm that PAM reads a regular /etc/motd, then edit that file.
  2. Need a changing value on Ubuntu or Debian? Add a numbered, executable script under /etc/update-motd.d.
  3. Need to remove only one vendor section? Add a same-named /etc/motd.d symlink to /dev/null.
  4. Need SSH-specific behavior? Check both PrintMotd and the SSH PAM configuration.
  5. Working on another distribution? Inspect its PAM files and MOTD directories first; do not assume the Debian/Ubuntu generator exists.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

DebianLinuxMOTDPAMSSHsystem administrationUbuntu

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.