Setting the default colours on linux virtual terminals (ttys)

-- 2025-04-12 --

I like to keep my environment as consistent as possible so I want the colours in the tty at start up to be the same as in my virtual terminals when I run a graphical interface.

There is a simple way to change the colours when you are working in a tty:

setvtrgb 

So, first install setvtrgb. On Void Linux this is contained in the kbd package.

setvtrgb will change the tty colours as indicated in FILENAME. FILENAME has to be in one of two formats. It could be a three line file with sixteen comma-seperated values (0-255):

32,204,133,181,32,211,26,176,56,255,133,191,38,255,43,218
32,34,153,114,133,54,145,176,56,58,197,187,139,60,177,218
32,31,0,50,204,130,136,176,56,55,0,0,255,175,184,218

The first line contains the red components of each colour, the second the green components and the third the red ones. I don't find this an easy format to deal with but if you're just making minor tweaks it's not too bad. You can create a file for editing from the current colour palette by running:

cat /sys/module/vt/parameters/default_{red,grn,blu} > CURRENT_COLS

The other file format that setvtrgb can read is sixteen lines with one hexadecimal triplet on each line:

#202020
#CC221F
#859900
#B57232
#2085CC
#D33682
#1A9188
#B0B0B0
#383838
#FF3A37
#85C500
#BFBB00
#268BFF
#FF3CAF
#2BB1B8
#DADADA

This is the format I use as it's easier to match with the colour palettes in my graphical applications which mostly use this format for their colors.

Running setvtrgb with one of the above file will immediately change the colour palette in all the ttys. However the changes won't survive a reboot.

To make the changes permanent and be there from start up you need to save a palette somewhere convenient. I save the file at

/etc/default/vt-colours

Then add the following line to /etc/rc.local:

setvtrgb /etc/default/vt-colours

That's it! Your new default colour palette will be used by all your ttys from boot.

Linux tips and guides
Home page