Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 stackoverflow.com 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

3 Answers 3

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

LS_COLORS='no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=0
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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.