Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Wrote a bash function to display the console colors.

But, it seems some of the colors are not possible to show that way! (?)

Also, note the strange "bright black"!

(Note: The below screendump is of xterm, but this is meant to be used in console mode. I had to use xterm to get a screendump. But it looks much the same.)


function clr () {
  Color_names="bla red gre yel blu mag cya whi"
  for m in {0..15}
    tput setaf $m
    echo -n ${Color_arr[$((m % 8))]}" "
  tput sgr0
  cat /sys/module/vt/parameters/default_red \
      /sys/module/vt/parameters/default_grn \
      /sys/module/vt/parameters/default_blu | tr "," "\t"
share|improve this question
Why do you think colors above 7 will work? man 5 terminfo only mentions 0-7. – Mikel Aug 24 '12 at 4:42
Well... it is clear now that that was where the shoe hurt. – Emanuel Berg Aug 24 '12 at 19:26
up vote 5 down vote accepted

If you check tput colors, you'll probably see that the answer is 8. The way to show the bright colors is by tput bold.

This shows all 8x8x2 combinations of foreground and background, normal and bold.

for cmd in sgr0 bold; do
  tput $cmd
  for i in $(seq 0 7); do
    for j in $(seq 0 7); do
      tput setaf $i; tput setab $j; echo -n " $i,$j "
    tput sgr0; echo; tput $cmd
share|improve this answer
I added tput reset because after breaking the lines 1) if the terminal output is scrolled up, the end of lines get filled with the last used color; 2) if the prompt sets no colors (or even if it sets, depending on the terminal) the next command will keep the last used color. I find it very ugly. Maybe reset was more than needed, I intended to use it as \e[0m equivalent. Update: you are right, should use tput sgr0 instead. – manatwork Aug 24 '12 at 10:50
Ok, just added that. Thanks. – angus Aug 24 '12 at 11:09
Awesome stuff! I'll edit the question with your stuff when I've integrated it with my table values. – Emanuel Berg Aug 24 '12 at 19:23

See this blog post: http://www.enigmacurry.com/2009/01/20/256-colors-on-the-linux-terminal/

Edit: if you have just 8 color result from tput-color you can use ncurses to solve your weakness! in ubuntu install it:

sudo apt-get install ncurses-term

and add the following line in your ~/.bashrc or ~/bash_profile:

export TERM=xterm-256color

and instead of your script you can use emacs command to see your colors. run emacs in terminal with emacs -nw and type command M-x list-colors-display

doesn't matter witch terminal do you have, this tools will work on all of your terminal emulators ;-)

share|improve this answer
Please summarize the article. Answers should be more than just a link. – Mikel Aug 24 '12 at 20:15
This blog post is about xterm. It doesn't apply to the Linux console. – Gilles Aug 24 '12 at 23:07
OK, still an interesting topic and a good effort! – Emanuel Berg Aug 25 '12 at 16:53

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.