Bringing some colour into your life

Sick of the same old black/white or black/green terminal emulator screen. Linux allows us to set various colours for different type of files - but how does it do this - and how can you change the colours?

I'd liked the feature ever since i first used linux but never really considered how it was working - i did a bit of digging today and found out how it works.

Lets start from the beginning...

ls is not calling ls directly any more - ls is an alias

alias ls='ls $LS_OPTIONS'

and what is in $LS_OPTIONS

-N --color=tty -T 0

so the clever bit here is that its added the --color option

looking at the man page this tells us that the colouring (not coloring - sorry had to get that in) is dependant on another environment variable LS_COLORS - lets see what's in that


And we get a list of all the mappings that are defined on my system, the first few parameters seem to relate to 'types' of file - i couldn't find a definite mapping for these but there must be a list somewhere - but some of them can be guessed - for instance fi is file and di is directory.

So in my case, files are colour 00 and directories are colour 01;34 - but what are colours 00 and 01;34?

00 just seems to be some default 'grey' colour, 01;34 seems to be bold blue. It seems a combination of 2 attributes is possible 01 seems to mean bold and 34 means blue.

So in your terminal emulator (putty in my case) - everything starts showing up in nice colours.

You can further add your own rules for certain file types, it you want file ending in .doc to show up in yellow you just add that rule to the LS_COLORS variable (*.doc=33 if you are interested)

Having the colour is very useful, i find it very good for just finding directories quickly and seeing which files are executable or not.

Anyway it's useful to know this function is there and a similar thing is applied to vi (well vim) and that also makes editing files easier.

Here is an example below of what things can look like

Here we can see directories are pale orange, zipped files are red executables are green etc

In this case everything was from the system defaults - however directories are defined as  01:34 (bold blue) is very hard to read against a black background.

I wanted to change this and it can be done quite easily as putty allows you to change the definition of the colours inside putty so colour 34 which would normally be blue can be changed to any colour you like - it's still called blue in the system but you can make it orange if you like.....

So in putty my blue is orange - this is changed in the options screen shown below

so red 255, green 128,blue 0 is "orange" - you can see this by clicking modify which shows you what the actual colour looks like.

Changing the setting in putty (while slightly confusing) is easier than changing the di= value in LS_COLORS on every server we have......


  1. vi is slightly easier to modify since you have built in color schemes:
    morning, peachpuff, blue, murphy, ron, zellner, darkblue, desert, koehler, shine etc

    all you need to do is:

    cd ~
    vi .vimrc
    colorscheme desert

    try and enjoy :)