from small one page howto to huge articles all in one place

search text in:

What does your sytem tell when running "ulimit -u"?

poll results

Last additions:
using iotop to find disk usage hogs

using iotop to find disk usage hogs






average rating: 1.7 (84 votes) (1=very good 6=terrible)

May 25th. 2007:




why adblockers are bad

Workaround and fixes for the current Core Dump Handling vulnerability affected kernels

Workaround and fixes for the current Core Dump Handling vulnerability affected kernels






average rating: 1.3 (28 votes) (1=very good 6=terrible)

April, 26th. 2006:

Druckversion . pdf icon
You are here: System->Tips and Tricks

ANSI Escape Sequences Colors

This tip shows the colors available as ANSI escape sequences. These can be used to beautify terminal prompts, text, or anything else that understands ANSI escape sequences.

ANSI escape sequences are non-printed text that is interpreted to change the format of some text. In this example, we will specifically look at the use of escape sequences to specify colors. In the standard Gentoo /etc/profile, there are some examples of these colors already being used to change the color of parts of the terminal prompt. For example, the pathname appears in blue and parts of the bash prompt show up in red or green depending on whether you are root or a normal user.

Non-printable ANSI escape sequences are always enclosed \[\033[ and \]. Colors must be followed by a m. Using the example from /etc/profile, we can see that the color code for green is 32, the code for blue is 34, and the code for red is 31.

Code Listing 1: PS1 from /etc/profile

// root user 
export PS1='\[\033[01;31m\]\h \[\033[01;34m\]\W \$ \[\033[00m\]' 
                      red               blue 
// normal user 
export PS1='\[\033[01;32m\]\u@\h \[\033[01;34m\]\W \$ \[\033[00m\]' 
                      green                blue

The next part is the 1 preceding the actual color code. This indicates whether or not the color should be bold or not (0 for normal, 1 for bold). So if you wanted a normal green instead of a bold green, you would use 00;32m instead of 01;32m.

Note: This does not work with all colors. See the list at the bottom for a list of what's available in bold.

For background colors you would 4x instead of 3x. So to have the background blue instead of the text, you could use 00;44m instead of 01;34m.

Here is a list of colors and their escape sequences.
Code Listing 2

    Black      0;30       Dark Gray    1;30 
    Red        0;31       Bold Red     1;31 
    Green      0;32       Bold Green   1;32 
    Yellow     0;33       Bold Yellow  1;33 
    Blue       0;34       Bold Blue    1;34  
    Purple     0;35       Bold Purple  1;35 
    Cyan       0;36       Bold Cyan    1;36 
    Light Gray 0;37       White        1;37

Note: ANSI sequence 0;33 is listed as Brown in the BASH-Prompt HOWTO, but it seems more of a mustard yellow. Strictly speaking, the bold version of it is indeed yellow - therefore I've listed it as yellow.


rate this article:
current rating: average rating: 1.6 (134 votes) (1=very good 6=terrible)
Your rating:
Very good (1) Good (2) ok (3) average (4) bad (5) terrible (6)

Support this site

Please read "Why adblockers are bad".

Other free services
Shorten long
URLs to short
links like
Reverse DNS lookup
Find out which hostname(s)
resolve to a
given IP or other hostnames for the server
rdf newsfeed | rss newsfeed | Atom newsfeed
- Powered by LeopardCMS - Running on Gentoo -
Copyright 2004-2017 Sascha Nitsch Unternehmensberatung UG(haftungsbeschränkt)
Valid XHTML1.1 : Valid CSS : buttonmaker
- Level Triple-A Conformance to Web Content Accessibility Guidelines 1.0 -
- Copyright and legal notices -
Time to create this page: 4.0 ms