I'm using the bash shell, and want to change some of my ls listing colors; I've noticed that this can be controlled using the LS_COLORS environment variable, which encodes terminal colors for various file and directory types and states.

Now, I have LS_COLORS set in my environment, but I don't remember / don't know who exactly sets it! I can't find any export LS_COLORS or even a mention of LS_COLORS in my .bashrc, .bash_login, etc.

So where is it set?

Note: I'm using a Debian-based distribution


The LS_COLORS variable is likely set using the GNU dircolors command - so the environment variable name is not used directly. A typical .bashrc fragment you would find on Debian-like systems would be:

if [ -x /usr/bin/dircolors ]; then
    test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
    alias ls='ls --color=auto'

So, here's what you want to do:

  • If ~/.dircolors doesn't exist, create it using dircolor -p > ~/.dircolors

  • Edit ~/.dircolors using your favorite text editor

  • Here's another man-like page explaining how to edit a dircolors database rather than the LS_COLORS variable

Now, whenever you start a new shell, you should get the colors you wanted.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.