Super User is a question and answer site for computer enthusiasts and power users. 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

When I type "ls" in the linux terminal the folder names should appear in green color and file name in black color. How do I do this?

share|improve this question

migrated from Feb 16 '11 at 8:46

This question came from our site for professional and enthusiast programmers.

I wonder why people actually are asking such questions, when running man ls should give you the answer quicker than waiting here until someone will give you the copy-paste solution. Is this the mindset? – Andrejs Cainikovs Feb 16 '11 at 8:52

These colors are defined in /etc/DIR_COLORS

For instance, I have the following line:

DIR 01;34       # directory

Which means:

  • 01 -> bold text
  • 34 -> blue

Attribute codes:
00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed

Text color codes:
30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white

Background color codes:
40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white

So basically:

FILE 30;47         # normal file, white bg, black fg
DIR 01;32       # directory, bold, green fg
share|improve this answer

You can specify ls --color, you can also use the LS_COLORS environment variable to configure the colors you want. For example:

LS_COLORS="fi=32:di=37" ls --color

should give you files in green and directories in grey (closest thing to black that's available). See this page on configuring LS_COLORS.

share|improve this answer
vi ~/.bashrc

then put the following lines

export LS_COLORS

save the changes

source ~/.bashrc

and the changes should apply every-time you login to the linux box

PS: you can adjust the color accordingly to your preference

share|improve this answer

You must log in to answer this question.