<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://www.marcelpost.com/wiki/index.php?action=history&amp;feed=atom&amp;title=Console-colours</id>
	<title>Console-colours - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://www.marcelpost.com/wiki/index.php?action=history&amp;feed=atom&amp;title=Console-colours"/>
	<link rel="alternate" type="text/html" href="https://www.marcelpost.com/wiki/index.php?title=Console-colours&amp;action=history"/>
	<updated>2026-04-29T12:34:13Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.17</generator>
	<entry>
		<id>https://www.marcelpost.com/wiki/index.php?title=Console-colours&amp;diff=3381&amp;oldid=prev</id>
		<title>Admin at 21:58, 13 May 2020</title>
		<link rel="alternate" type="text/html" href="https://www.marcelpost.com/wiki/index.php?title=Console-colours&amp;diff=3381&amp;oldid=prev"/>
		<updated>2020-05-13T21:58:11Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;When working with Linux remotely over ssh it&amp;#039;s sometimes nice to be able to work with a different colour scheme (or color scheme as some write). With ssh clients like Putty it&amp;#039;s easy to change the foreground and background colours of the characters, but Linux supports different colours for different types of data; sometimes based on the file extension, sometimes based on functionality (e.g. directory names, command prompt, current working directory, bold text, links, etc..). &lt;br /&gt;
&lt;br /&gt;
Below are listed the most commonly used colour sets and some instructions on how to change them.&lt;br /&gt;
&lt;br /&gt;
===change bash prompt colours===&lt;br /&gt;
&lt;br /&gt;
The bash prompt can show colors for username, hostname and current working directory.&lt;br /&gt;
&lt;br /&gt;
The colours as well as the components that determine what the prompt should contain are all set in the PS1 environment variable.&lt;br /&gt;
&lt;br /&gt;
The PS1 string is usually set in ~/.bashrc and can look something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
PS1=&amp;#039;${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ &amp;#039;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Pay attention at the part \u@\h it is saying &amp;quot;user@host&amp;quot; and the number before it \[\033[01;32m\] indicates the color. This is what needs changing if you want a different colour.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The \u and \h are the username and hostname, but there are more:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
\u    username&lt;br /&gt;
\h    system host name&lt;br /&gt;
\w    current (working) directory&lt;br /&gt;
\$    show a # if the effective UID is 0 (i.e. root user), otherwise display a $&lt;br /&gt;
\a    unknown&lt;br /&gt;
\@    time in 12-hour am/pm format&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The full PS1 string looks quite complicated, but here is it broken up into the various pieces:&lt;br /&gt;
&lt;br /&gt;
Set a colour and display the username, @-sign and hostname&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
\[\033[01;32m\]\u@\h       &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remove any colour codes (use the terminal default) and display the &amp;#039;:&amp;#039; sign&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
\[\033[00m\]:&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set a colour and display the current working directory&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
\[\033[01;34m\]\w&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once again disable any colour codes and display just the &amp;#039;$&amp;#039; sign&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
\[\033[00m\]\$&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The actual colour is defined by the semicolon-separated number pair that is inside the inner square brackets (e.g. &amp;#039;01;32&amp;#039;). All the extra stuff is just escape characters and color-begin and color-end markers.&lt;br /&gt;
&lt;br /&gt;
The colors numbers are:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Black       0;30     Dark Gray     1;30&lt;br /&gt;
Blue        0;34     Light Blue    1;34&lt;br /&gt;
Green       0;32     Light Green   1;32&lt;br /&gt;
Cyan        0;36     Light Cyan    1;36&lt;br /&gt;
Red         0;31     Light Red     1;31&lt;br /&gt;
Purple      0;35     Light Purple  1;35&lt;br /&gt;
Brown       0;33     Yellow        1;33&lt;br /&gt;
Light Gray  0;37     White         1;37&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===change manpage colors===&lt;br /&gt;
&lt;br /&gt;
When man pages are viewed, they are piped through a program called &amp;#039;less&amp;#039;, which offers page navigation and search capabilities of the man-page text.&lt;br /&gt;
&lt;br /&gt;
The idea is to override the colour settings that less uses.&lt;br /&gt;
&lt;br /&gt;
edit and add the following lines to ~/.bashrc to load up the new colourscheme.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
export LESS_TERMCAP_mb=$(printf &amp;#039;\e[01;31m&amp;#039;) # enter blinking mode - red&lt;br /&gt;
export LESS_TERMCAP_md=$(printf &amp;#039;\e[01;35m&amp;#039;) # enter double-bright mode - bold, magenta&lt;br /&gt;
export LESS_TERMCAP_me=$(printf &amp;#039;\e[0m&amp;#039;) # turn off all appearance modes (mb, md, so, us)&lt;br /&gt;
export LESS_TERMCAP_se=$(printf &amp;#039;\e[0m&amp;#039;) # leave standout mode    &lt;br /&gt;
export LESS_TERMCAP_so=$(printf &amp;#039;\e[01;33m&amp;#039;) # enter standout mode - yellow&lt;br /&gt;
export LESS_TERMCAP_ue=$(printf &amp;#039;\e[0m&amp;#039;) # leave underline mode&lt;br /&gt;
export LESS_TERMCAP_us=$(printf &amp;#039;\e[04;36m&amp;#039;) # enter underline mode - cyan&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The color codes are as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    30 – black&lt;br /&gt;
    31 – red&lt;br /&gt;
    32 – green&lt;br /&gt;
    33 – orange&lt;br /&gt;
    34 – blue&lt;br /&gt;
    35 – magenta&lt;br /&gt;
    36 – cyan&lt;br /&gt;
    37 – white&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Some other escape codes which you could use include:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    0 – reset/normal&lt;br /&gt;
    1 – bold&lt;br /&gt;
    3 – italic/reversed&lt;br /&gt;
    4 – underlined&lt;br /&gt;
    5 – blink&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===change vi (vim) colours===&lt;br /&gt;
&lt;br /&gt;
The vi editor has a range of color schemes available that are defined in /usr/share/vim/vim74/colors/&lt;br /&gt;
&lt;br /&gt;
Adding:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
colo blue&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
..to ~/.vimrc will use the &amp;#039;blue&amp;#039; colorscheme. Other options are:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
darkblue&lt;br /&gt;
default&lt;br /&gt;
delek&lt;br /&gt;
desert&lt;br /&gt;
elflord&lt;br /&gt;
evening&lt;br /&gt;
industry&lt;br /&gt;
koehler&lt;br /&gt;
morning&lt;br /&gt;
murphy&lt;br /&gt;
pablo&lt;br /&gt;
peachpuff&lt;br /&gt;
ron&lt;br /&gt;
shine&lt;br /&gt;
slate&lt;br /&gt;
torte&lt;br /&gt;
zellner&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You could of course also type: &amp;#039;colo blue&amp;#039; on the vi status line to immediately change to it.&lt;br /&gt;
&lt;br /&gt;
The status line is what appears after you press the &amp;lt;ESCAPE&amp;gt; key and type a : (the colon symbol)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Add the following line to your ~/.vimrc to change the bottom line text color (that shows the edit mode, INSERT or REPLACE):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
hi ModeMsg term=bold ctermfg=2 gui=bold guifg=SeaGreen&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
When &amp;#039;su&amp;#039; -ing into another account, the .vimrc of that su account will override the .vimrc from the account you were coming from.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
More options:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
hi LineNr ctermfg=grey guifg=grey&lt;br /&gt;
hi Statement ctermfg=black guifg=black&lt;br /&gt;
hi Identifier ctermfg=darkGreen guifg=darkGreen&lt;br /&gt;
hi Comment term=bold ctermfg=4 guifg=#406090&lt;br /&gt;
hi Constant term=underline ctermfg=Red guifg=#c00058&lt;br /&gt;
hi Special term=bold ctermfg=Blue guifg=SlateBlue&lt;br /&gt;
hi Identifier term=underline ctermfg=Black guifg=Black&lt;br /&gt;
hi Statement term=bold ctermfg=Brown gui=bold guifg=Brown&lt;br /&gt;
hi PreProc term=underline ctermfg=Magenta guifg=Magenta3&lt;br /&gt;
hi Type term=underline ctermfg=Green gui=bold guifg=SeaGreen&lt;br /&gt;
hi Ignore cterm=bold ctermfg=7 guifg=bg&lt;br /&gt;
hi Error term=reverse cterm=bold ctermfg=7 ctermbg=1 gui=bold guifg=White guibg=Red&lt;br /&gt;
hi Todo term=standout ctermfg=0 ctermbg=3 guifg=Blue guibg=Yellow&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To see all the available (and currently configured color schemes) type the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
hi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Lastly, vim has been configured on some systems to support Syntax Highlighting. Some find this fantastic, others find this annoying. To turn it off, type &amp;#039;syntax off&amp;#039; on the status line or include it in your .vimrc file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===change directory and file type colours===&lt;br /&gt;
&lt;br /&gt;
In some cases you may want to change the file type colours that appear when viewing a directory listing in Linux.&lt;br /&gt;
&lt;br /&gt;
Normally, directories are dark blue, .gz files are red, executables are green, etc..&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
The colours are managed by the LS_COLORS environment variable which can be easily modified with the utility &amp;#039;dircolors&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
Step 1 – Copy the current LS_COLORS to a file in your home folder.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dircolors &amp;gt; ~/.dir_colors&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Step 2 – Edit the files to make whatever changes you require.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vi ~/.dir_colors&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Step 3 – load the new color scheme whenever a shell starts&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
echo &amp;quot;. ~/.dir_colors&amp;quot; &amp;gt;&amp;gt; ~/.bashrc&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
NOTE: when using &amp;#039;su&amp;#039; the color scheme is inherited from the user you were logged in as. So if the colours while in &amp;#039;su&amp;#039; are not to your liking, you need to change the dircolors scheme for the pre-su-user, not root.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
You will notice that the LS_COLORS variable contains many definitions. The dircolors utility has a way of displaying the colour definitions a bit nicer:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dircolors --print-database&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
The first number is the style (1=bold), followed by a semicolon, and then the actual number of the color, possible styles are:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
0   = default colour&lt;br /&gt;
1   = bold&lt;br /&gt;
4   = underlined&lt;br /&gt;
5   = flashing text&lt;br /&gt;
7   = reverse field&lt;br /&gt;
40  = black background&lt;br /&gt;
41  = red background&lt;br /&gt;
42  = green background&lt;br /&gt;
43  = orange background&lt;br /&gt;
44  = blue background&lt;br /&gt;
45  = purple background&lt;br /&gt;
46  = cyan background&lt;br /&gt;
47  = grey background&lt;br /&gt;
100 = dark grey background&lt;br /&gt;
101 = light red background&lt;br /&gt;
102 = light green background&lt;br /&gt;
103 = yellow background&lt;br /&gt;
104 = light blue background&lt;br /&gt;
105 = light purple background&lt;br /&gt;
106 = turquoise background&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
All possible colors:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
31  = red&lt;br /&gt;
32  = green&lt;br /&gt;
33  = orange&lt;br /&gt;
34  = blue&lt;br /&gt;
35  = purple&lt;br /&gt;
36  = cyan&lt;br /&gt;
37  = grey&lt;br /&gt;
90  = dark grey&lt;br /&gt;
91  = light red&lt;br /&gt;
92  = light green&lt;br /&gt;
93  = yellow&lt;br /&gt;
94  = light blue&lt;br /&gt;
95  = light purple&lt;br /&gt;
96  = turquoise&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These can even be combined, so that a parameter like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
di=1;4;31;42&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
in your LS_COLORS variable would make directories appear in bold underlined red text with a green background!&lt;br /&gt;
&lt;br /&gt;
You can also change other kinds of files when using the ls command by defining each kind with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
di = directory&lt;br /&gt;
fi = file&lt;br /&gt;
ln = symbolic link&lt;br /&gt;
pi = fifo file&lt;br /&gt;
so = socket file&lt;br /&gt;
bd = block (buffered) special file&lt;br /&gt;
cd = character (unbuffered) special file&lt;br /&gt;
or = symbolic link pointing to a non-existent file (orphan)&lt;br /&gt;
mi = non-existent file pointed to by a symbolic link (visible when you type ls -l)&lt;br /&gt;
ex = file which is executable (ie. has &amp;#039;x&amp;#039; set in permissions).&lt;br /&gt;
*.rpm = files with the ending .rpm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After you alter your .bashrc file, to put the changes in effect you will have to restart your shell.&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
</feed>