The contents of /etc/motd are displayed by pam_motd after a successful login over ssh but just before it executes the login shell such as bash. You will see messages as follows on screen:
However, Ubuntu Linux uses update-motd which is a dynamic MOTD generation tool. From the man page:
UNIX/Linux system adminstrators often communicate important information to console and remote users by maintaining text in the file /etc/motd, which is displayed by the pam_motd(8) module on interactive shell logins.
Traditionally, this file is static text, typically installed by the distribution and only updated on release upgrades, or overwritten by the local administrator with pertinent information.
Ubuntu introduced the update-motd framework, by which the motd(5) is dynamically assembled from a collection of scripts at login.
Executable scripts in /etc/update-motd.d/* are executed by pam_motd(8) as the root user at each login, and this information is concatenated in /var/run/motd. The order of script execution is determined by the run-parts(8) –lsbsysinit option (basically alphabetical order, with a few caveats).
How do I view current scripts?
Type the following cd command:
$ cd /etc/update-motd.d/
$ ls -l
Use the cat command to view scripts:
$ cat 90-updates-available
How do I disable the script?
To disable all script run the following chmod command:
sudo chmod -R 0644 /etc/update-motd.d/
sudo chmod -xR /etc/update-motd.d/
To disable an individual script run:
sudo chmod 0644 /etc/update-motd.d/50-motd-news
sudo chmod -x /etc/update-motd.d/50-motd-news
Verify it with the ls command:
$ ls -l /etc/update-motd.d/
$ ls -l /etc/update-motd.d/50-motd-news
-rw-r--r-- 1 root root 4196 Feb 16 01:24 /etc/update-motd.d/50-motd-news
How to create my own script in /etc/update-motd.d/ directory?
Just create a shell script as follows:
$ sudo vi /etc/update-motd.d/99-my-messages
#!/bin/sh echo echo "Unauthorized access to this device is prohibited." echo "For support call xxx-yyy-zzz or write to [email protected]" echo
Set executable permissions:
$ chmod +x /etc/update-motd.d/99-my-messages