I know there are several related questions asked about this but I could't solve my problem with those.

Expected behavior:
What I want is to disable all coloring stuff and just make the directories magenta. In other words : --color=never + magenta directories.

Current behavior:
ls already reads my LS_COLORS environment variable but I also see the green background for directories too. It seems like the LS_COLORS is just an override to the default coloring.

What I've done so far:

  1. I edited my ~/.bashrc file, set the LS_COLORS manually and exported it.
  2. I noticed that there is a section in this file that tries to run dircolors program so that it sets the LS_COLORS. But since I'm doing it myself I commented it out:
# enable color support of ls and also add handy aliases                               
#if [ -x /usr/bin/dircolors ]; then                                                   
#    test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolor> 
#    alias ls='ls --color=auto'                                                       
#    #alias dir='dir --color=auto'                                                    
#    #alias vdir='vdir --color=auto'                                                  
#    alias grep='grep --color=auto'                                                   
#    alias fgrep='fgrep --color=auto'                                                 
#    alias egrep='egrep --color=auto'                                                 
  1. This is how I set it:
LS_COLORS='di=01;35'; export LS_COLORS                                                
alias ls='ls --color=auto' 

Again, the above line works. If I change 35 to 34 I would see the difference.

But what is annoying is I only want this color and nothing else:

enter image description here

Isn't ls supposed to only read this variable for coloring?

1 Answer 1


ls has default colours for several file types, and all of them need to be overridden if you don’t want them to be applied.

In your case,

eval $(dircolors -p | awk '/^TERM/ { print; next } /^[A-Z]/ { $2 = "00" } /^DIR/ { $2 = "01;35" } /^\./ { next } 1' | dircolors -)

will clear all the defaults and set the colour for directories.

  • I see. I thought ls would get its information only from LS_COLORS but it turns out that it's mostly for overridden. I replaced my single ''di=01;35'' with the result of this and it works like a charm. Thanks.
    – S.B
    Sep 18, 2022 at 14:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .