Ask Ubuntu is a question and answer site for Ubuntu users and developers. 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

On my console the color for directories is such a blue, that it is hard to read on a dark background.

How can I change the color definitions for ls?

share|improve this question
up vote 60 down vote accepted

To change your directory colors, open up your ~/.bashrc file with your editor

nano ~/.bashrc

and make the following entry at the end of the file:

LS_COLORS=$LS_COLORS:'di=0;35:' ; export LS_COLORS

Some nice color choices (in this case 0;35 it is purple) are:

Blue = 34
Green = 32
Light Green = 1;32
Cyan = 36
Red = 31
Purple = 35
Brown = 33
Yellow = 1;33
white = 1;37
Light Grey = 0;37
Black = 30
Dark Grey= 1;30

The first number is the style (1=bold), followed by a semicolon, and then the actual number of the color, possible styles are:

0   = default colour
1   = bold
4   = underlined
5   = flashing text
7   = reverse field
40  = black background
41  = red background
42  = green background
43  = orange background
44  = blue background
45  = purple background
46  = cyan background
47  = grey background
100 = dark grey background
101 = light red background
102 = light green background
103 = yellow background
104 = light blue background
105 = light purple background
106 = turquoise background

All possible colors:

31  = red
32  = green
33  = orange
34  = blue
35  = purple
36  = cyan
37  = grey
90  = dark grey
91  = light red
92  = light green
93  = yellow
94  = light blue
95  = light purple
96  = turquoise

These can even be combined, so that a parameter like:


in your LS_COLORS variable would make directories appear in bold underlined red text with a green background!

You can also change other kinds of files when using the ls command by defining each kind with:

di = directory
fi = file
ln = symbolic link
pi = fifo file
so = socket file
bd = block (buffered) special file
cd = character (unbuffered) special file
or = symbolic link pointing to a non-existent file (orphan)
mi = non-existent file pointed to by a symbolic link (visible when you type ls -l)
ex = file which is executable (ie. has 'x' set in permissions).
*.rpm = files with the ending .rpm

After you alter your .bashrc file, to put the changes in effect you will have to restart your shell.


share|improve this answer
This works well, thanks. I personally found it better to set LS_COLORS=$LS_COLORS:'di=1;44:' ; export LS_COLORS which shows the directories in bold white over blue background. – Igal Mar 18 at 18:52
This doesn't seem to work for me. It looks like there is another config file somewhere that overwrites .bashrc - some colors work, others look differently. Folders are green for instance instead of blue, but files look correctly. What could it be? – Nearoo Jul 9 at 8:42
check if you are using bash or sh, and also check your .profile file in your home directory. and global /etc/bash.bashrc – rubo77 Jul 9 at 9:52

Very simple Add these three lines to ~/.bashrc

root@hostname# vi ~/.bashrc
export LS_OPTIONS='--color=auto'
eval "`dircolors`"
alias ls='ls $LS_OPTIONS'

If you want to apply the changes, type the following in your home directory:

root@hostname# . .bashrc
share|improve this answer


This is a collection of extension:color mappings, suitable to use as your LS COLORS environment variable.

share|improve this answer

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.