Custom Login Message
There are a number of ways of customizing the message you get when you log in. The traditional way for admin's to let users know the latest information is by changing the text in /etc/motd (Message of the Day), which is then displayed to users as they log in.
If you want to change the prompt you receive when you first log into your computer (you won't see this if you have KDM or GDM running and boot straight into a graphical desktop) you can edit /etc/issue.
Those are both fairly simple things and don't give you many options. They can't run anything for example, so you can't have a customised message, nor can you change it for each login.
The way give each user a custom message when they log in, you can change the file /etc/bashrc. This file affects all users, if you just want to change it for a single user edit the file /home/user/bashrc. (In fact it's best to test this in your own user account first, before applying it to the whole system, in case you make a mistake.
When editing the /etc/bashrc file you need to ensure that you don't cause problems for non-interactive logins, such as used by scp and similar tools. To do this you need to ensure that you have a login shell before displaying your custom login. Most bashrc scrips will already test for this, usually by using something similar to:
# are we an interactive shell? if [ "$PS1" ]; then
The best place for the custom login message is inside this if block.
In my case, I created a BASH script called pretty_login, which I placed in /usr/bin so that it's accessible to all and then gave read and execute permission to all users. I then call this from my /etc/bashrc. I find it's easier to call another script as that makes editing my custom login easier, especially if I upgrade my distro.
/usr/bin/pretty_login
The script I use calls fortune to provide me with a random quote and uses ANSI Escape Codes to give the login some colour, you can of course edit this script to do whatever you want, or even write your own script.
#!/bin/bash ###################################################### # Script to show a nice prompt. # # Author: Martin Gill # # No restrictions on use, no warranty given, # implied or otherwise. # ###################################################### # Instructions # # Instructions are for Mandriva systems, but should # work with minor or no modification on most systems # (I hope). # # Copy this script into /usr/bin and give +x to all users # edit /etc/bashrc and call this script after the [ "$PS1" # line in that file. It is important to call it within the # $PS1 if clause so that login isn't broken for non- # interactive logins used for programs like scp. # # This script is intended for BASH on terminals that # understand ansi escape sequences. # #define ansi codes black='\E[30;40m' red='\E[31;40m' green='\E[32;40m' yellow='\E[33;40m' blue='\E[34;40m' magenta='\E[35;40m' cyan='\E[36;40m' white='\E[37;40m' bold='\E[1m' none='\E[0m' username=`whoami` #get the username hostname=`hostname` #get the hostname # Set the quote colour echo -e $yellow # run fortune with my favourite fortunes # full path used as users like root don't have games in their path /usr/games/fortune homer chalkboard futurama discworld #sperator line and change colours echo -e "$white$bold---$none" "$blue$bold" #the greeting for our user echo -e "Hello $red$username$blue, welcome to $magenta$hostname\n" #reset the terminal to default values #(undo all the colours and bold and stuff) tput sgr0
