Account Links: Cart | Your Account | Logout

Skip to content

Red Hat Knowledgebase

Red Hat Knowledgebase Search:

Updated Within the Last:

New Solutions within the last day New Solutions within the last week New Solutions within the last month

Browse by topics:


Click to View a Topic
Red Hat Enterprise Linux > Configuration > Issue <<  252 of 606 >>

Solution Tools:


Email a Solution Postcard Printer version Submit a comment on this answer Update notifications Request an answer Back

Article Reference

Article ID: 3926
Last update: 09-24-04
Issue:
How do I change the color of text in a terminal or virtual console?
Resolution:
Release Found: Red Hat Enterprise Linux

Problem:
You need to display text in a terminal or virtual console but would like it to display in a pre-determined color.

Solution:
To change the color in or within a string of characters, prefix one of the codes from the table below with the escape character (ASCII code- 27 decimal, 0x1b hex, or 033 octal), followed by a [ character (ASCII code- 91 decimal, 0x5b hex, or 133 octal), and follow the code with the letter m (ASCII code- 109 decimal, 0x6d hex, or 155 octal). If you specify only escape, bracket and the letter m, without any codes inbetween, then the text properties will revert back to their default

For example, try typing the following at a shell prompt:

 
$ echo -e "This is normal text - \033\1331;33;44\155 This is yellow 
on blue text\033\133\155"
This is normal text   -    This is yellow on blue text

Table of color codes:
0;30;40 0;30;41 0;30;42 0;30;43 0;30;44 0;30;45 0;30;46 0;30;47
0;31;40 0;31;41 0;31;42 0;31;43 0;31;44 0;31;45 0;31;46 0;31;47
0;32;40 0;32;41 0;32;42 0;32;43 0;32;44 0;32;45 0;32;46 0;32;47
0;33;40 0;33;41 0;33;42 0;33;43 0;33;44 0;33;45 0;33;46 0;33;47
0;34;40 0;34;41 0;34;42 0;34;43 0;34;44 0;34;45 0;34;46 0;34;47
0;35;40 0;35;41 0;35;42 0;35;43 0;35;44 0;35;45 0;35;46 0;35;47
0;36;40 0;36;41 0;36;42 0;36;43 0;36;44 0;36;45 0;36;46 0;36;47
0;37;40 0;37;41 0;37;42 0;37;43 0;37;44 0;37;45 0;37;46 0;37;47
1;30;40 1;30;41 1;30;42 1;30;43 1;30;44 1;30;45 1;30;46 1;30;47
1;31;40 1;31;41 1;31;42 1;31;43 1;31;44 1;31;45 1;31;46 1;31;47
1;32;40 1;32;41 1;32;42 1;32;43 1;32;44 1;32;45 1;32;46 1;32;47
1;33;40 1;33;41 1;33;42 1;33;43 1;33;44 1;33;45 1;33;46 1;33;47
1;34;40 1;34;41 1;34;42 1;34;43 1;34;44 1;34;45 1;34;46 1;34;47
1;35;40 1;35;41 1;35;42 1;35;43 1;35;44 1;35;45 1;35;46 1;35;47
1;36;40 1;36;41 1;36;42 1;36;43 1;36;44 1;36;45 1;36;46 1;36;47
1;37;40 1;37;41 1;37;42 1;37;43 1;37;44 1;37;45 1;37;46 1;37;47
4;30;40 4;30;41 4;30;42 4;30;43 4;30;44 4;30;45 4;30;46 4;30;47
4;31;40 4;31;41 4;31;42 4;31;43 4;31;44 4;31;45 4;31;46 4;31;47
4;32;40 4;32;41 4;32;42 4;32;43 4;32;44 4;32;45 4;32;46 4;32;47
4;33;40 4;33;41 4;33;42 4;33;43 4;33;44 4;33;45 4;33;46 4;33;47
4;34;40 4;34;41 4;34;42 4;34;43 4;34;44 4;34;45 4;34;46 4;34;47
4;35;40 4;35;41 4;35;42 4;35;43 4;35;44 4;35;45 4;35;46 4;35;47
4;36;40 4;36;41 4;36;42 4;36;43 4;36;44 4;36;45 4;36;46 4;36;47
4;37;40 4;37;41 4;37;42 4;37;43 4;37;44 4;37;45 4;37;46 4;37;4


For more information on the many terminal emulation escape codes available please see http://vt100.net/.


How well did this entry answer your question?


good wrong incomplete out of date
Red Hat Enterprise Linux > Configuration > Issue <<   252  of  606  >>