You are scripting console setup for a batch of bare-metal installs and need a repeatable way to set the virtual terminal palette. setvtrgb takes a palette file, decimal or hexadecimal, and applies it to a virtual terminal. This guide builds a tested palette file and shows a clear way to apply it. It uses setvtrgb from kbd 2.6.4, installed here as package version 2.6.4-2ubuntu2. Allow about ten minutes. You need a shell, the kbd package and permission to write to the target console.
Safety note: applying a palette changes the colours shown by the selected virtual terminal. It does not change application output, terminal emulator themes or the contents of a file. Keep a backup palette so you can restore the previous state, and do not use a real console device as a scratch target unless you are comfortable changing its display.
Check the exact option syntax before using an example copied from another system:
$ setvtrgb --version
setvtrgb from kbd 2.6.4
The command accepts one palette argument: vga, a file path, or - for standard input. It also accepts -C DEV or --console=DEV to select the console device. The version output and the package version can differ in how the distribution labels the build, so record both when troubleshooting.
Checkpoint: if setvtrgb --version is not found, install or repair the distribution's kbd package before making a palette. Do not substitute a similarly named terminal-colour utility without checking its interface.
The kernel exposes the current default red, green and blue tables as three files. Use the documented brace expansion to save them as one decimal palette file:
$ palette_backup="${TMPDIR:-/tmp}/setvtrgb-before.txt"
$ cat /sys/module/vt/parameters/default_{red,grn,blu} > "$palette_backup"
$ wc -l "$palette_backup"
3 /tmp/setvtrgb-before.txt
Choose a directory private to you if the palette is sensitive to your workstation setup; the example uses a temporary path because this is a recovery copy, not a permanent configuration. The file should have exactly three lines, each with 16 comma-separated decimal values: all red values first, then all green values, then all blue values.
Inspect it before continuing:
$ cat "$palette_backup"
0,170,0,170,0,170,0,170,85,255,85,255,85,255,85,255
0,0,170,170,0,0,170,170,85,85,255,255,85,85,255,255
0,0,0,0,170,170,170,170,85,85,85,85,255,255,255,255
Your values will normally differ. Do not edit this backup in place. If the virtual terminal parameter files are missing, stop here: the host may not expose the virtual terminal interface, and a palette file alone will not fix that.
Hexadecimal files are easier to review because each of the 16 lines names one complete RGB colour. Create a new file with a text editor, or use this controlled example:
test_palette="${TMPDIR:-/tmp}/setvtrgb-test.hex"
cat > "$test_palette" <<'EOF'
#000000
#AA0000
#00AA00
#AA5500
#0000AA
#AA00AA
#00AAAA
#AAAAAA
#555555
#FF5555
#55FF55
#FFFF55
#5555FF
#FF55FF
#55FFFF
#FFFFFF
EOF
This is the complete VGA-style 16-colour sequence from the command's documentation. A hexadecimal palette must contain exactly 16 lines, each a number sign followed by a six-digit hexadecimal triplet. Order matters: line 1 is colour index 0 and line 16 is index 15.
Verify the shape without applying it:
$ awk 'NF && $0 !~ /^#[[:xdigit:]]{6}$/ { bad=1 } END { if (NR != 16 || bad) exit 1 }' "$test_palette"
$ printf 'palette lines: '; wc -l < "$test_palette"
palette lines: 16
The validator checks the line count and basic form only. setvtrgb does the actual format detection and rejects malformed input. Do not add comments or blank lines to this file.
Warning: the next command changes the display colours of a virtual terminal. Test it on a console you control, and keep the backup from step 2. Applying a file does not create a persistent service or boot configuration, but it does change the current terminal state.
On the current console, apply the test file with elevated privileges if the device permissions require them:
$ sudo setvtrgb "$test_palette"
There is no success message to rely on. If the command exits without an error, switch between readable text and the 16 colour indexes to confirm the result visually. Check the exit status immediately if you need a scriptable record:
$ sudo setvtrgb "$test_palette"
$ printf 'setvtrgb exit status: %s\n' "$?"
setvtrgb exit status: 0
Use the explicit device form when the target is not the console selected by the command's default:
$ sudo setvtrgb --console=/dev/tty1 "$test_palette"
The device must be the virtual terminal you intend to affect. Confirm its path against your host's console setup before running the command: a terminal emulator window is not automatically the same thing as /dev/tty1.
If the colours are hard to read, restore the decimal backup. This uses the same three-line format produced in step 2:
$ sudo setvtrgb "$palette_backup"
$ printf 'restore exit status: %s\n' "$?"
restore exit status: 0
If the backup was stored under /tmp, it may disappear after a reboot or cleanup job. For a palette you will reuse, copy a verified file to a controlled system location and record who may edit it; the command itself gives you no rollback history.
The argument vga is another built-in choice:
$ sudo setvtrgb vga
Use it when you specifically want the utility's standard VGA palette. Use your saved file when you need to return to the exact values that were active before the change.
#RRGGBB. If the command rejects a file, count lines first and check for spaces, comments, blank lines or a missing number sign.sudo, and verify the selected device rather than granting broad write permissions.setvtrgb affects Linux virtual terminals; it does not recolour an X terminal emulator, a Wayland terminal window or an application's own colour scheme. If only one emulator looks wrong, investigate that emulator's configuration instead.setvtrgb versions.vga palette.