LinuxCommandLibrary

motd

TLDR

Edit static MOTD

$ sudo nano /etc/motd
copy
View MOTD
$ cat /etc/motd
copy
Add dynamic MOTD script
$ sudo nano /etc/update-motd.d/[99-custom]
copy
Make dynamic script executable
$ sudo chmod +x /etc/update-motd.d/[99-custom]
copy
Regenerate dynamic MOTD
$ run-parts /etc/update-motd.d/
copy

SYNOPSIS

/etc/motd

DESCRIPTION

motd (Message of the Day) is displayed to users upon login. It can be a static text file or dynamically generated from scripts.
On systems with PAM, /etc/motd is displayed after successful authentication. Dynamic MOTD systems run scripts from /etc/update-motd.d/.

STATIC MOTD

$ # /etc/motd
Welcome to myserver
Authorized users only
copy

DYNAMIC MOTD

$ #!/bin/bash
# /etc/update-motd.d/10-sysinfo
echo "System: $(uname -n)"
echo "Uptime:$(uptime -p)"
echo "Users: $(who | wc -l)"
copy

FILE LOCATIONS

$ /etc/motd              - Static message
/etc/update-motd.d/    - Dynamic scripts
/run/motd.dynamic      - Generated output
copy

CAVEATS

Dynamic MOTD requires update-motd package. Scripts must be executable. SSH may have separate banner. PAM configuration affects display.

SEE ALSO

login(1), sshd(8), pam(8), wall(1)

Copied to clipboard