Saturday 7 June 2014

How to Create a Dynamic "Message Of The Day"

  • Create a File under /etc/profile.d/motd.sh

  • Copy & Paste the below script into MOTD.SH file
#################################################################################
#!/bin/bash

# Creates a colorful & informative "message of the day (motd)".
# Save as /etc/profile.d/motd.sh


# Setting variables for ANSI colors

White="\033[01;37m"
Green="\033[01;34m"
Green="\033[0;32m"

# Displaying colorful info: hostname, OS, kernel and username.

echo
echo -e "$Green===================================================$Green
Welcome to $White$(hostname)$Green.
This system is running $White$(cat /etc/redhat-release)$Green.
Kernel version $White$(uname -r)$Green.
You're currently logged in as $White$(whoami)$Green.
$Blue===================================================$Blue"
echo

# Calling the "cowsay" program.


echo -e $White
echo
~

#################################################################################

  • Change Permission of File

  • # chmod +x motd.sh

  • Now try and Login.  



Thanks & Regards,

Nilesh Chandekar

No comments:

Post a Comment