What is motd linux

Put a Talking Cow in Your Linux Message of the Day

There are a lot of cool old Linux commands that we don’t see anymore because they’re buried under our flashy graphical desktops. But they’re still there, they’re still fun, and best of all they’re configured with nice easy text files. MOTD, or Message of the Day, has evolved from a simple text file to an entire scripted framework that can display ANSI art, static text messages, and display dynamic system information.

Message of the Day

Message of the Day, or motd , displays a message on console logins. You can see this in action by pressing Ctrl+Alt+F2 to get to a console, and then login. Or open an SSH session to another Linux PC. This is how it looks on Linux Mint:

Welcome to Linux Mint 13 Maya (GNU/Linux 3.2.0-23-generic x86_64) Welcome to Linux Mint * Documentation: http://www.linuxmint.com Last login: Thu Oct 3 09:25:53 2013

But that is boring, and I want it to look like this:

/ BOFH excuse #365: | | | parallel processors running | perpendicular today / ----------------------------- ^__^ (oo)_______ (__) )/ ||----w | || || _____ ____ _ __ __ / ___/____ ___ __ / __/____(_)__ ____ ____/ / ____ _____ ____/ / __ / __ `/ / / / / /_/ ___/ / _ / __ / __ / / __ `/ __ / __ / ___/ / /_/ / /_/ / / __/ / / / __/ / / / /_/ / / /_/ / / / / /_/ / /____/__,_/__, / /_/ /_/ /_/___/_/ /_/__,_/ __,_/_/ /_/__,_/ /____/ __ __ ___ ____ / /____ _____/ / / _ / __ / __/ _ / ___/ / / __/ / / / /_/ __/ / /_/ ___/_/ /_/__/___/_/ (_)

How you do these depends on your Linux distro. In the olden days the message came from /etc/motd , and most distros still use this. So all you do to change the message is edit /etc/motd , in plain text. Easy peasey and fun. But this doesn’t let you run fun commands, like cowsay and fortune . There is a way around this, which I shall return to in a moment.

MOTD on Debian and Ubuntu

Debian and Ubuntu use a dynamic scripting framework, update-motd . It uses a batch of scripts in /etc/update-motd that are executed by the pam_motd module when users login, and information from the various scripts is assembled in /var/run/motd . /etc/motd is symlinked to /var/run/motd , so anything you write in it will be overwritten. So what if you want to put your own inspirational message in MOTD on Debian and Ubuntu? /etc/update-motd.d/99-footer is reserved for this, but it’s a shell script so you can’t just add a text message, but must use shell commands. Here is a simple example that outputs two lines of text separated by linebreaks:

printf "n wakka wakka wakka n n wakka n"
Welcome to Linux Mint 13 Maya (GNU/Linux 3.2.0-23-generic x86_64) Welcome to Linux Mint * Documentation: http://www.linuxmint.com wakka wakka wakka wakka Last login: Wed Sep 11 19:53:56 2013

You can read the files in /etc/update-motd to see which scripts the other lines come from, and if you want to find all the scripts that touch MOTD try running sudo grep -ir motd /etc . Or read man update-motd .

Читайте также:  Узнать версию smb linux

Jazzing Up Your MOTD With Fortune and Cowsay

Wouldn’t you prefer to have a talking cow deliver a different fortune when you login?

___________________________________________________________ / Q: What's tiny and yellow and very, very, dangerous? A: A canary with the super-user password. / ----------------------------------------------------------- ^__^ (oo)_______ (__) )/ ||----w | || ||

On Debian and Ubuntu, install fortune-mod and cowsay . There are many different fortune databases you can install, which you can find with apt-cache search fortune . They’re all plain text files so you can easily edit them and add your own messages, if you feel creative. Then add this line to /etc/update-motd.d/99-footer :

exec /usr/games/fortune | /usr/games/cowsay -n

Now you’ll get a fortune wrapped in cowsay at every login. You can test it on the command-line like this:

$ /usr/games/fortune | /usr/games/cowsay -n ___________________________________________________ / Q: Why did the chicken cross the road? | A: To see his friend Gregory peck. | | | | Q: Why did the chicken cross the playground? | A: To get to the other slide. / --------------------------------------------------- ^__^ (oo)_______ (__) )/ ||----w | || ||

You can even specify a specific fortune database, such as /usr/games/fortune bofh-excuses | /usr/games/cowsay -n

Do the same for figlet : just pop a line into /etc/update-motd.d/99-footer , like this:

exec figlet -f digital Welcome and be assimilated
+-+-+-+-+-+-+-+ +-+-+-+ +-+-+ +-+-+-+-+-+-+-+-+-+-+-+ |W|e|l|c|o|m|e| |a|n|d| |b|e| |a|s|s|i|m|i|l|a|t|e|d| +-+-+-+-+-+-+-+ +-+-+-+ +-+-+ +-+-+-+-+-+-+-+-+-+-+-+

Other Distros

What about distros with the old-fashioned static MOTD? No worries, because you can make use of the global login profile to run scripted login messages. Create a file named /etc/profiles.d/motd.sh , and enter your commands in it like this:

/usr/games/fortune | /usr/games/cowsay -n figlet -f slant Say friend and enter! echo "Wipe your feet and mind your manners"

Yes, it is that easy, and your console login will look something like this:

_____________________________________________ / Today's weirdness is tomorrow's reason why. -- Hunter S. Thompson / --------------------------------------------- ^__^ (oo)_______ (__) )/ ||----w | || || _____ ____ _ __ __ / ___/____ ___ __ / __/____(_)__ ____ ____/ / ____ _____ ____/ / __ / __ `/ / / / / /_/ ___/ / _ / __ / __ / / __ `/ __ / __ / ___/ / /_/ / /_/ / / __/ / / / __/ / / / /_/ / / /_/ / / / / /_/ / /____/__,_/__, / /_/ /_/ /_/___/_/ /_/__,_/ __,_/_/ /_/__,_/ /____/ __ __ ___ ____ / /____ _____/ / / _ / __ / __/ _ / ___/ / / __/ / / / /_/ __/ / /_/ ___/_/ /_/__/___/_/ (_) Wipe your feet and mind your manners

You can use any shell commands and pretty it up with ANSI colors. This example displays current system information in colors:

HOSTNAME=`uname -n` KERNEL=`uname -r` CPU=`uname -p` ARCH=`uname -m` # The different colours as variables W="33[01;37m" B="33[01;34m" R="33[01;31m" X="33[00;37m" echo "$R#===================================================#" echo " $W Welcome $B $USER $W to $B $HOSTNAME " echo " $R ARCH $W= $ARCH " echo " $R KERNEL $W= $KERNEL " echo " $R CPU $W= $CPU " echo "$R#==================================================#"
#==================================================# Welcome carla to studio ARCH = x86_64 KERNEL = 3.8.0-31-generic CPU = x86_64 #==================================================#

Another advantage to doing it this way is you can quickly test your changes by running the script directly:

Читайте также:  Linux device drivers one pdf

Consult the Bash reference manual and the man pages of the various commands to learn more ways to customize your MOTD, and check your own distro documentation just in case they’ve made any funny tweaks to MOTD.

Источник

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:

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.

Читайте также:  How to reboot linux command

About the author

Shehroz Azam

A Javascript Developer & Linux enthusiast with 4 years of industrial experience and proven know-how to combine creative and usability viewpoints resulting in world-class web applications. I have experience working with Vue, React & Node.js & currently working on article writing and video creation.

Источник

How to Show MOTD in Linux?

MOTD (stands for “Message of the Day”) is a message that is displayed to users when they log in to a Linux system. The MOTD is displayed after a user successfully logs in to the server using ssh. The MOTD is typically stored in a file called “/etc/motd”, and it can be used to provide users with important information, such as announcements, security advisories, or system status updates.

This article aims to explain various methods to show the MOTD in Linux. The content of this tutorial is mentioned below:

Let’s start with the prerequisite.

Prerequisite: Check the SSH Services

To check the services of ssh, the “systemctl” utility is used with the “status” option as below:

$ sudo systemctl status sshd

How to Add MOTD in Linux?

To customize the MOTD on the system, you can edit the “/etc/motd” file using a text editor such as vi or nano. Use the sudo command to gain the necessary privileges to edit this file.

It navigates to the particular file using the “sudo” privilege. After that, add the message according to choice. For instance, a message is written as below:

How to Show the MOTD in Linux?

To display the MOTD in Linux, you can use the “cat” command to view the contents of the “/etc/motd” file. The added MOTD will be displayed after executing the script:

Alternatively, you can use the less command to view the contents of the “/etc/motd” file in a paginated format:

Make File Executable

Make sure to set the script to be executable with “chmod +x” command and then run it with “/etc/motd” to test it.

After the successful execution of the command, login to the server.

Verify MOTD During Login to Server

To verify the MOTD in Linux; users can log in to the server by specifying the “IP address”. It requires password authentication to log in to the server:

The output shows that “”””” Itslinuxfoss World ”””””” has been shown in Linux.

That is how to show the MOTD in Linux.

Conclusion

Linux offers the “cat” command to display the “MOTD” in the terminal. After modification in the “/etc/motd” file, the user can display the custom MOTD during login to the server. MOTD is a useful tool for providing users with important information and updates about the system. This guide has explained all possible steps to show the MOTD on the login screen of Linux.

Источник

Оцените статью
Adblock
detector