Linux – How to set default console background/foreground colors

debianlinux

I have to administrate a few dozen Linux Debian boxes with PuTTY (occasionally also with Terminal on MacOS). Typically, after a few hours of work there are lots of console windows open.

I would like to configure each box to use a different (random) background color so that there is a strong visual feedback on which system I am typing at any particular time. I simply want to avoid mistakes like copying data from the test system onto the production system, instead of the other way round.

Please advise how to set up the system so that the default console background/foreground color can be defined.
I know how to do that in the PuTTY configuration however I need this set on the system itself as I do not want to have a special PuTTY configuration for each system, also it should work exactly the same on the MacOS X Terminal.

Best Answer

On the systems I have to hand putty identifies itself as an xterm. This basically gives you 8 colours to play with

You can set the background colour of with

tput setab n; tput clear

where n is 0-7. You can extend this by changing the value of $TERM so

export TERM=xterm-256color 

will allow 256 colours 0-255.

For some backgrounds you'll definitely want to change the foreground colour use

tput setaf n ; tput clear

again n is terminal type dependant.

The command reset is handy when playing with the colour combinations.