50.2 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:
This should produce followed by the login prompt, next time getty starts up.
The line responsible for the color is:
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.
Your donation will support ongoing availability and give you access to the PDF version of this book. Desktop Survival Guides include Data Science, GNU/Linux, and MLHub. Books available on Amazon include Data Mining with Rattle and Essentials of Data Science. Popular open source software includes rattle, wajig, and mlhub. Hosted by Togaware, a pioneer of free and open source software since 1984. Copyright © 1995-2022 Graham.Williams@togaware.com Creative Commons Attribution-ShareAlike 4.0