Linux by default has the /etc/motd that usually on some distributions is either completely removed or file empty or it contains some information regarding the exact Linux distribution version and numbering and that it comes with no warranty at all – example case for /etc/motd for a distro is Debian's /etc/motd (NO WARRANTY) famous message.
Exchanging this annoying message that is printed on every console tty login, in X session GUI terminal tool on the gnome-terminal / konsole / xterm as well as on each remote SSH session is easy if you have superuser credentials on the Linux server host, however if you're employed in a company and just having a single set of restricted access via LDAP or sudo credentials, that might be not possible.
Thus to save yourself the annoyance to read this reapparing company logo message or distribution non-sense information for each and every bash shell login, it is possible to do it on most Linux distributions via .an embedded feature that the bash shell understands via creation of simple empty file called
.hushlogin
Thus to get rid of the annoying /etc/motd message simply login with your user and do:
$ touch ~/.hushlogin
That's all folks on next login the message is gone !
There is other cases in which you might be the system administrator of a shared shell system and you want to inform the users about recent updates or planned Upgrade schedules under which the system will be unavailable lets say for a system reboot. to apply latest security or version updates.
Thus you might want to add an additional file under which you might want to inform all active UNIX shell users from a certain location.
To do that you can use a sipmle script to run on every login via:/etc/profile.d/print-msg-on-each-login.sh
To create this simple additional print message mechanism
1. Create /etc/profile.d/print-msg-on-each-login.sh script
$ vim /etc/profile.d/print-msg-on-each-login.sh
#!/bin/bash
MSG_FILE=/etc/print_global_message
NOMSG_IND=~/.no_global_message
GID=$(id -g)[[ $UID -ne 0 && $GID -ne 212 && -e $MSG_FILE && ! -e $NOMSG_IND ]] && cat $MSG_FILE >&2
2. Edit file /etc/print_global_message and add the mssage to print on each user login
$ echo -e 'System reboot at 03:00 A.M.\n\n Please save all your data !\n To get rid of this message, run cmd\n $ touch /etc/.no_global_message ' >> /etc/print_global_message
That's all you're done now on next login you will get on the shell the message.
System reboot at 03:00 A.M.
Please save all your data !
To get rid of this message, run cmd
$ touch /etc/.no_global_message
If you want to omit the message for your non-root user simply follow the instructions and run the touch command.
$ > /etc/.no_global_message
What we learned ?
How to disable /etc/motd message if such is there to not appear on every login by creating ~/.hushlogin
As a sysadmin, how to configure an additional infromative messages via /etc/print_global_message, that could be disabled
by touching /etc/.no_global_message.