Go to TogaWare.com Home Page. GNU/Linux Desktop Survival Guide
by Graham Williams
Duck Duck Go



CLICK HERE TO VISIT THE UPDATED SURVIVAL GUIDE

Login Screen

When you log in on the console of your Linux System, you are usually presented with a login screen with information about the system you are about to log in on. You can change what you see on your login screen as well as adding a bit of colour.

When your GNU/Linux system boots it starts getty processes on a number of virtual terminals on your system. When getty starts it prints the contents of /etc/issue to the terminal. It is this file that can be modified to customise the look of your console.

You can add colour to your console through the use of escape sequences that can be used to change the appearance of text on screen. For example, you could pipe the output from the following script into /etc/issue to try it out (perhaps take a backup copy of /etc/issue first):

  #!/bin/sh
  
  spaces()
  { 
    COUNT=0; 
    while [ $COUNT -lt $1 ]; 
    do 
      echo -ne " ";
      COUNT=$[$COUNT+1] 
    done 
  }
  
  esc="\033[" 
  echo -ne  "${esc}H${esc}J\n${esc}44;37;1m"
  WELCOME="Welcome to "`hostname`" running Linux "`uname -r`
  CHARS=$[(80-`echo $WELCOME | wc --chars`)/2] 
  echo -ne $WELCOME `spaces $CHARS`
  echo -ne "${esc}0m\n "
Save the above to a file, perhaps called update-issue. Then, as root, do the following:
  # cp /etc/issue issue.backup
  # sh update-issue > /etc/issue
This should produce Welcome to athens.togaware.com running Linux 2.6.9-1-686-smp followed by the login prompt, next time getty starts up.

The line responsible for the color is:

echo -ne "${esc}H${esc}J\n${esc}44;37;1m"

In this case the 44;37 specifies White on Blue. To produce a nice colout table on your terminal, to see what is available, you can run the following code (either cut-n-paste it into a terminal or else save it to a file and execute that file, as we did above:

#!/bin/bash
# Display ANSI colours. 
#
esc="\033["
echo -n " _ _ _ _ _40 _ _ _ 41_ _ _ _42 _ _ _ 43"
echo "_ _ _ 44_ _ _ _45 _ _ _ 46_ _ _ _47 _"
for fore in 30 31 32 33 34 35 36 37; do
  line1="$fore  "
  line2="    "
  for back in 40 41 42 43 44 45 46 47; do
    line1="${line1}${esc}${back};${fore}m Normal  ${esc}0m"
    line2="${line2}${esc}${back};${fore};1m Bold    ${esc}0m"
  done
  echo -e "$line1\n$line2"
done

Note that some GUN/Linux distributions overwrite /etc/issue at boot time.

The scripts above originated from gpf@linuxuser.co.za.


Support further development by purchasing the PDF version of the book.
Other online resources include the Data Science Desktop Survival Guide.
Books available on Amazon include Data Mining with Rattle and Essentials of Data Science.
Popular open source software includes rattle and wajig.
Hosted by Togaware, a pioneer of free and open source software since 1984.
Copyright © 1995-2020 Togaware Pty Ltd. Creative Commons ShareAlike V4.