I installed mailutils on my linux machine with Linux Mint 15 (basically Ubuntu 13.04).When I log in, I get the following:Welcome to Linux Mint 15 Olivia (GNU/Linux 3.8.0-32-generic i686)Welcome to Linux Mint * Documentation:  http://www.linuxmint.comNo mail.Last login: Wed Nov  6 01:33:10 2013 from xxxxxxxxxxxxxxxxxxxxxxxBFL SingleSC: 3s ago - [2013-11-06 01:37:33] 5s:57.83 avg:57.96 u:56.96 Gh/sI have added the last line, colorized as I prefer, as a custom script that updates me on the status of my BFL bitcoin hashing rig in ~/.bashrc.I now want to color the rest of it, especially the No mail. line, from mailutils, and remove the duplicated 'Welcome to Linux Mint' messages and newline.I've been searching for the mailutils section specifically, and can't find any reference to it in:~/.bashrc~/.profile/etc/profile/etc/profile.d/*/etc/bashrc/etc/init.d/*/etc/rc.local/etc/rc*.d (1, 2, 3, 4, 5, 6, S)So - how do I go about finding where these messages are generated so I can modify and color them as I like?
How do I track down the source of a ssh login message?
scripting;login;bashrc;profile;mail command
Updated answer based on some researchingRemove duplicated welcome messagesSince you login with ssh, the first welcome message should be coming from /etc/issue.net. To remove the message, just remove the contents of that file.To remove the second welcome message, remove the contents of /etc/motd.Colorize the line about mailTo colorize that line, the easiest option I can think of requires quite a bit of low-level work: the option is that you modify and build pam_mail.so yourself.These are the steps for modifying it and installing the modified versionDownload Linux-PAM source from linux-pam.org (the official project site).Extract the source (this will create a new directory named Linux-PAM-1.1.8) and cd to it:# tar xzvf Linux-PAM-1.1.8.tar.gz# cd Linux-PAM-1.1.8Change the following lines (the lines which begins with +, 4 lines at all) in file modules/pam_mail/pam_mail.c to be as the following diff shows (produced with diff -u)(the filename pam_mail.c.new is just my temporary file that I could produce that diff):--- pam_mail.c  2013-06-18 17:11:21.000000000 +0300+++ pam_mail.c.new      2013-12-29 16:57:49.759298926 +0200@@ -294,17 +294,17 @@          switch (type)            {            case HAVE_NO_MAIL:-             retval = pam_info (pamh, %s, _(No mail.));+             retval = pam_info (pamh, %s, _(\\033[0;1;31mNo mail.\\033[0m));              break;            case HAVE_NEW_MAIL:-             retval = pam_info (pamh, %s, _(You have new mail.));+             retval = pam_info (pamh, %s, _(\\033[0;1;31mYou have new mail.\\033[0m));              break;            case HAVE_OLD_MAIL:-             retval = pam_info (pamh, %s, _(You have old mail.));+             retval = pam_info (pamh, %s, _(\\033[0;1;31mYou have old mail.\\033[0m));              break;            case HAVE_MAIL:            default:-             retval = pam_info (pamh, %s, _(You have mail.));+             retval = pam_info (pamh, %s, _(\\033[0;1;31mYou have mail.\\033[0m));              break;            }        elseI have simply added \\033[0;1;31m to the beginning of those messages and \\033[0m to the end of those messages.Note: Now it displays those messages as red; from ascii-table.com page about Ansi Escape Sequences under title Set Graphics Mode you can find more complete list about colors and other tricks about customising terminal output.Compile it (Note: from here to the end I assume that your working directory is Linux-PAM-1.1.8, the very same directory to which we cd'd at the beginning, i.e. the root directory of the Linux-PAM package):# ./configure# makeBackup your existing pam_mail.so in case that the new one breaks your system (I doubt it will break, but it's always good to have the original file in safe):# cp /lib/i386-linux-gnu/security/pam_mail.so ~/Copy the file modules/pam_mail/.libs/pam_mail.so to /lib/i386-linux-gnu/security/:# cp modules/pam_mail/.libs/pam_mail.so /lib/i386-linux-gnu/security/Log out and again in (or start a new ssh session, whatever), and you should see red No mail. message (assuming you have no new mail).The old, obsolete answerThe mail message can be disabled by changing the following line in file /etc/pam.d/system-login fromsession optional pam_mail.so dir=/var/spool/mail standardtosession optional pam_mail.so dir=/var/spool/mail nopenReference from archlinux's forums.The text before the mail information is in /etc/motd, and you can disable it to be printed when login with ssh by putting the following line to ~/.ssh/config:PrintMotd no