Linux Command Reference ยท Special Files and Directories
The /etc/motd and /etc/issue files
Reference for /etc/motd, /etc/issue and /etc/issue.net: the message of the day, pre-login banners, escape codes, dynamic motd scripts and the SSH Banner option.
Linux can show text to people who log in. There are three common places, shown at different moments:
/etc/issueis printed on text consoles before the login prompt. It often names the distribution and supports escape codes for host name, tty and so on./etc/issue.netis the same idea for remote logins by Telnet, and is what SSH shows when you pointBannerat it./etc/motd("message of the day") is printed after a successful login, for announcements such as maintenance windows.
They are plain text files with no special syntax, apart from the escape sequences in issue.
cat /etc/motd cat /etc/issue sudo nano /etc/motd
Try it
Press Run (or Ctrl + Enter) to see the result here.
Program input ยท what you'd type while the program runs
Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.
Press Run (or Ctrl + Enter) to see the result here.
Program input ยท what you'd type while the program runs
Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.
Syntax
Escape codes understood by agetty in /etc/issue:
| Code | Replaced with |
|---|---|
\n |
Host name. |
\s |
Operating system name (Linux). |
\r |
Kernel release. |
\m |
Machine architecture (x86_64). |
\l |
Terminal line, for example tty1. |
\d, \t |
Date and time. |
\4, \6 |
IPv4 or IPv6 address of the interface (agetty with an interface argument). |
/etc/motd and /etc/issue.net are printed as-is. On Debian and Ubuntu, /etc/motd is often a link to a generated file, and /etc/update-motd.d/ holds numbered scripts whose output builds the dynamic message.
Usage notes
- SSH pre-login banner: set
Banner /etc/issue.netin/etc/ssh/sshd_configand reloadsshd. This is shown before authentication and is the right place for legal notices. - Silence the motd for yourself: create an empty
~/.hushlogin. It suppresses the message of the day and last-login line for that user. - Dynamic motd: make a script executable in
/etc/update-motd.d/(50-news, for example) and print text; scripts run in numeric order as root at login. Keep them fast, since they delay every login. - RHEL family: uses
/etc/motdand/etc/motd.d/(all files are shown) pluscockpithints. - Do not leak information. The default
issuemay reveal exact distribution and kernel versions, which helps attackers. Hardening guides replace it with a short legal notice. See hardening. - Updates: distribution upgrades can overwrite
/etc/issue; add local text to/etc/issue.d/where supported, or protect the file with your configuration management. - Wording: include a clear statement of authorized use, but ask a lawyer about legal effect; it is not a security control.