How to Show MOTD in Linux
MOTD is the abbreviation of “Message Of The Day”, and it is used to display a message when a remote user login to the Linux Operating system using SSH. Linux administrators often need to display different messages on the login of the user, like displaying custom information about the server or any necessary information. To show custom MOTD, this post will guide you on how to show MOTD in Linux.
Add Additional Message
We can provide any text to display on the login of the remote user to the machine by creating a new file with the name of motd in /etc directory. To create and edit the /etc/motd file, we will use the nano editor:
In this blank file, you can add any text of your choice that you want to show as MOTD.
For example, we can write “Welcome to the Linuxhint’s first machine”. After writing this message, save it and close the nano editor using the keyboard shortcuts CTRL+S and CTRL+X.
After writing the MOTD and saving the /etc/motd file. Get the IP address of the server system using the command typed below:
Log in from any other machine from the network through SSH for testing purposes, and provide the IP address of the server followed by SSH command as shown below:
If you are going to log in for the first time, it will ask to authenticate the connection so type “yes” and hit Enter.
After that, the terminal will prompt for the password of the user. Type the password, and hit Enter to log in to the server’s machine.
Here in the output screenshot, you can see that the message we created is displayed successfully.
So this is how simple and easy we write a custom message and show MOTD in Linux.
Now, what if we don’t want all other default text messages and provide the only custom MOTD. For this purpose, we just need to disable or remove the executable permissions of all the MOTD files and scripts. To disable the executable permissions, type the command:
$ sudo chmod -x /etc/update-motd.d/*
After disabling the executable permissions of MOTD scripts, log back into the server’s machine from the other machine via SSH.
You can witness how efficiently all the default MOTD messages are gone, and we have the clean custom MOTD.
Conclusion
This post provides a simple and easy solution on how to show MOTD in Linux by creating a new MOTD file in the /etc directory and writing the desired message in it. Moreover, we have learned to disable the default MOTD message and show custom MOTD.