Problem
I practically “live” on the Linux command line and one thing that has been bugging me for so long that now I decided to do something about it. On my company’s Linux systems the ls command produces color output, which makes it easy to distinguish different file types. However, the directories are dark blue which makes it nearly impossible to see against the black background.
My Solution
To fix the problem, my research took me to the LS_COLORS environment variable and a command named dircolors. The solution is to set the LS_COLORS environment variable to control how the ls command chooses its color. I can set the LS_COLORS variable manually, but there is a better way which employes the dircolors command.
The dircolors command output commands to set the LS_COLORS environment. It also output the colors in human-readable format, allowing easy modifications.
To use the dircolors, the first step is to save the current settings into a file. From the terminal, I issued one of the following commands:
dircolors -p > ~/dircolors.txt
The next step is to edit the file ~/dircolors.txt. This file’s format is easy to understand and self-documented; I had no problem finding the file that begins with “DIR” and change the color to my taste.
Next, I try out the new color scheme:
eval $( dircolors -b ~/dircolors.txt ); ls # bash shell syntax
eval `dircolors -b ~/dircolors.txt`; ls # C shell syntax
After finding the color scheme I liked, I saved it to my start up file:
dircolors -b ~/dircolors.txt >> ~/.profile # bash shell
dircolors -b ~/dircolors.txt >> ~/.cshrc # C shell
From this point on, I no longer have to put up with hard-to-see colors.
Solution for BSD Systems
On BSD systems, which includes the Mac OS X, the variable in question is LSCOLOR (note the lack of the underscore character). The format of this variable is different from the Linux’s LS_COLORS. The default is exfxcxdxbxegedabagacad. The value of this variable consists of pairs of characters; the first character is the code for foreground color, and the second is for background. Please consult the man page for ls on BSD for more information.
The Interactive Solution
While I like to do things the hard way to learn more about the inner-working of the OS, there is a more interactive way: point your browser here to an interactive online web application which assist you in setting the colors. After finding your desired color scheme, you still have to cut and paste it to your start up file.
Additional References
Google is your friend: do a search for LSCOLORS or LS_COLORS will result in more information that you ever care to read.

I believe your C shell syntax should read as follows:
dircolors -c ~/dircolors.txt >> ~/.cshrc # C shell
when I tried your code, -b caused it to output a bunch of bourne shell stuff that my shell didn’t like too much. -c worked fine though. =)
and thanks! this was very helpful.
Comment by nathan — June 6, 2009 @ 1:10 am
oh, also applies for the section above the line i mentioned:
eval `dircolors -b ~/dircolors.txt`; ls # C shell syntax
should be
eval `dircolors -c ~/dircolors.txt`; ls # C shell syntax
Comment by nathan — June 6, 2009 @ 1:11 am
I preferred actually removing the colour, rather than changing it.
Having a colour ls output is usually caused by having an alias for ls in some configuration file somewhere. If you can remove that alias, you can usually remove the colours.
Alternatively you can put the following command into your .bashrc, .profile or whatever:
unalias ls
That should take ls back to its original state.
Comment by Jamie Brown — June 24, 2009 @ 3:16 pm
Linux color management relies on the use of accurate International Color …. Mac OS X loads LUT adjustments automatically, while Linux and Microsoft not. In my laptop, I have tried this.
Comment by carrel678 — July 8, 2009 @ 5:04 am
[...] Changing Directory Listing (ls) in RHEL Filed under: Unix — Hai @ 9:27 pm This is a follow-up to my previous post. [...]
Pingback by Changing Directory Listing (ls) in RHEL « Hai’s Blog — September 3, 2009 @ 9:27 pm