MOTD after login in Arch Linux

MOTD – Message Of The Day is a text which is in /etc/motd and is showed after login.
Before login text is in /etc/issue

The man pam_motd example suggests the following line added to /etc/pam.d/login

session  optional  pam_motd.so  motd=/etc/motd

After login the following last line should appear:

Last login: Fri Dec 05 12:05:11 2014 from tty2

On http://unix.stackexchange.com/a/125583/39470 is revealed the path of the lastlog file:

$ strings /bin/login | grep last
/var/log/lastlog
write lastlog failed

My /etc/profile.d/motd.sh

#
# /etc/profile.d/motd.sh

MOTD_DATE=`date`
#MOTD_KERNEL=`uname -r`
#MOTD_MEMORY=`free -m | awk 'NR==2 { printf "RAM:  %sMB, Used: %sMB, Free: %sMB",$2,$3,$4; }'`
#MOTD_SWAP=`free -m | awk 'NR==3 { printf "SWAP: %sMB, Used: %sMB, Free: %sMB",$2,$3,$4; }'`
#MOTD_DISKS=`df -h /dev/sdb1 /dev/sda1 /dev/sdc1`
MOTD_MEMORY=`free -m | awk '/Mem/ { printf("%3.1f%%", $3/$2*100) }'`
MOTD_SWAP=`free -m | awk '/Swap/ { printf("%3.1f%%", $3/$2*100) }'`
MOTD_ROOT=`df -h / | awk '/\// {print $(NF-1)}'`
MOTD_HOME=`df -h /home | awk '/\/home/ {print $(NF-1)}'`
MOTD_MEDIA=`df -h /media/sdb1 | awk '/\/media\/sdb1/ {print $(NF-1)}'`

# clear # to clear the screen when showing up

printf "Today is $MOTD_DATE\n\n"
printf "mem: \t%s" $MOTD_MEMORY
printf "\tswap: \t%s\n\n" $MOTD_SWAP
printf "/ \t\t%s\n" $MOTD_ROOT
printf "/home \t\t%s\n" $MOTD_HOME
printf "/media/sdb1 \t%s\n\n" $MOTD_MEDIA

mail
Advertisements

About Michal Zuber

Full stack developer, biker and rollerblader. Owner and developer at https://nevilleweb.sk/ Co-founded http://neville.sk/ Blog at https://michalzuber.wordpress.com/
This entry was posted in cli, linux and tagged . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s