Tuesday, October 17, 2017

Script to set motd in linux machine

Just Copy and paste below mentioned commands in one file and assign executable permission to the file. it will set the motd in your machine

#!/bin/bash
#define the filename to use as output
motd="/etc/motd"
HOSTNAME=`uname -n`
KERNEL=`uname -r`
CPU=`nproc`
ARCH=`cat /etc/lsb-release | grep DISTRIB_DESCRIPTION`
# The different colours as variables
W="\033[01;37m" # WHITE
B="\033[01;34m" # BLUE
G="\033[01;32m" # GREEN 
R="\033[01;31m" # RED
X="\033[00;37m" # Light Gray
Y="\033[00;93m" # Yellow
C="\033[00;36m" # Cyan
M="\033[00;35m" # Magenta
RESET="\033[0m"
clear > $motd # to clear the screen when showing up

echo -e "                                                                      " >> $motd
echo -e "  $R _______   $M  _____    $X ______    $G _     _   $C ______ " >> $motd
echo -e "  $R      (_______) $M  / ___ \ $X  (_____ \ $G  | |   | |$C  |  ___ \ " >> $motd
echo -e "  $R       _____    $M | |   | |$X   _____) )$G  | |   | |$C  | | _ | | " >> $motd
echo -e "  $R      |  ___)   $M | |   | |$X  (_____ ( $G  | |   | |$C  | || || | " >> $motd
echo -e "  $R      | |       $M | |___| |$X        | | $G | |___| |$C  | || || | " >> $motd
echo -e "  $R      |_|       $M  \_____/  $X       |_| $G  \______|$C  |_||_||_| " >> $motd
echo -e " " >> $motd
echo -e " #=============================================================================# " >> $motd
echo -e "       $R Welcome $R to $R Motadata Forum                " >> $motd
echo -e "       $C Forum URL$C= http://forum.motadata.com                " >> $motd
echo -e "       $B KERNEL   $B= $KERNEL                                 " >> $motd
echo -e "       $M CPU Core $M= $CPU                              $RESET " >> $motd
echo -e "       $G ARCH     $G= $ARCH                              $RESET " >> $motd
echo -e "$C #=============================================================================#$RESET " >> $motd

1 comment: