screencap of ls output on linux machine

There are two directories shown by 'ls'. Normally directories anywhere are blue on black background. But the first one is blue on green and impossible to read. Why is this? How to make it blue on black, or at least something light on something dark?

This is on Ubuntu 12.04, using bash in Gnome Terminal. In Konsole, the blue is slightly darker, and possible to read, though could be way better.

10 Answers 10


Apart from coloring files based on their type (turquoise for audio files, bright red for Archives and compressed files, and purple for images and videos), ls also colors files and directories based on their attributes:

  • Black text with green background indicates that a directory is writable by others apart from the owning user and group, and has the sticky bit set (o+w, +t).
  • Blue text with green background indicates that a directory is writable by others apart from the owning user and group, and does not have the sticky bit set (o+w, -t).

Stephano Palazzo over at Ask Ubuntu has made this very instructive picture over the different attribute colors:

What the different colors mean in the terminal

As terdon pointed out, the color settings can be modified via dircolors. A list of the different coloring settings can be accessed with dircolors --print-database.

Each line of output, such as BLK 40;33;01, is of the form:

  • TARGET indicates the target for the coloring rule

  • TEXT_STYLE indicates the text style:

    • 00 = none
    • 01 = bold
    • 04 = underscore
    • 05 = blink
    • 07 = reverse,
    • 08 = concealed
  • FOREGROUND_COLOR indicates the foreground color:

    • 30 = black
    • 31 = red
    • 32 = green
    • 33 = yellow
    • 34 = blue,
    • 35 = magenta
    • 36 = cyan
    • 37 = white
  • BACKGROUND_COLOR indicates the background colors:

    • 40 = black
    • 41 = red
    • 42 = green
    • 43 = yellow
    • 44 = blue,
    • 45 = magenta
    • 46 = cyan
    • 47 = white

Fields may be omitted starting from the right, so for instance .tar 01;31 means bold and red.

XTerm and most other modern terminal emulators support 256 colors.

A XTerm 256-color foreground color code is of the form:


A XTerm 256-color background color code is of the form:


where both FOREGROUND_COLOR and BACKGROUND_COLOR is a number the range 0-255. A full list of color codes for the 16 and 256 color modes are shown in the below screenshot:

16 and 256 color mode color codes

  • 1
    so what does green only foreground mean? like I have here? Commented May 12, 2020 at 11:22
  • @ChagaiFriedlander: Executable files (see bottom row in the picture). Commented May 12, 2020 at 11:56

The colors of ls can represent the permissions; the defaults for some systems is to show directories where everyone has write permissions with a green background:

enter image description here

You can change the colors by editing your $LS_COLORS variable using dircolors (from man ls):

   Using color to distinguish file types is disabled both by  default  and
   with  --color=never.  With --color=auto, ls emits color codes only when
   standard output is connected to a terminal.  The LS_COLORS  environment
   variable can change the settings.  Use the dircolors command to set it.

The syntax is admittedly kind of annoying here but you can change this color by creating a file with the colors you want and saving it as ~/.dircolors:

dircolors -p > ~/.dircolors

That command will print the defaults into ~/.dircolors. You will then need to edit that file and change this line:

OTHER_WRITABLE 34;42 # dir that is other-writable (o+w) and not sticky

For example, to make it black text on a red background (see here for a list of color codes):

OTHER_WRITABLE 30;41 # dir that is other-writable (o+w) and not sticky

You don't need to have all the defaults, you can also just create a file with a single line, redefining just the one you want to change. Anyway, once you have created the file, load it with:

eval "$(dircolors ~/.dircolors)";

And here it is in action:

enter image description here

To have that happen automatically, add the eval command above to your ~/.bashrc file.

  • 21
    The default colors often seem to indicate the original author hates us and our eyes though...
    – kurtm
    Commented Oct 10, 2013 at 20:00
  • 1
    Thanks. WHy do you sometimes write ~/.dirname, and sometimes ~/dircolors, and sometimes ~/.dircolors? are they supposed to be the same?
    – Tim
    Commented Mar 26, 2015 at 15:42
  • 1
    Thanks. Why eval "$(dircolors ~/dircolors)"; instead of more direct way such as dircolors ~/dircolors?
    – Tim
    Commented Oct 22, 2015 at 15:27
  • 1
    @Tim because dircolors only prints the settings, you need to eval it in order for them to be read.
    – terdon
    Commented Oct 22, 2015 at 15:58
  • 1
    @Tim dircolors ~/.dircolors will just read the .dircolors file and format it as a variable. The output is simply something like LS_COLORS='foo=bar:baz=gaz'. A variable and the value it is set to. In order for that to take effect, you need to actually set LS_COLORS to that value and that is what eval does.
    – terdon
    Commented Oct 22, 2015 at 23:05

tldr; How to just fix it?

To quickly fix the problem:

  • Makes other-writable files show up as yellow on nobg
  • Edit your shell profile (e.g. ~/.bashrc, ~/.profile, etc) to make this permanent.

More details:

Replace 33 by 34 for blue on nobg. Even simpler, to make it nofg on nobg:


To make your change permanent, append it to your .profile:

echo "export LS_COLORS+=':ow=01;33'" >> ~/.profile

To view the non-extension related rules of LS_COLORS:

echo "$LS_COLORS" | sed 's/:/\n/g' | grep -v '\*.'

sed puts each rule on one line and grep removes the rules beginning by *.'.

To explore the ls colors on your terminal, consider using

function sc () {
    echo "$LS_COLORS" | sed 's/:/\n/g' | grep -v '\*.'
function t () {
    ls /mnt # Or the path to your example directory.



As stated in another answer (that of Thomas Nyman), 38;5; is the prefix for foreground x-term 256-colors, and 48;5; for background x-term 256-colors. 256-colors isn't supported by all terminals though.

Also see -What do the different colors mean in ls?- on AskUbuntu.

  • 1
    I found dropping LS_COLORS+=':ow=01;33' into my ~/.zshrc helped disable color-background for directories in a git-repo. This is on a Windows 10 machine with a Pengwin-WSL distribution. Now all directories within git-repo are readable.
    – llinfeng
    Commented Nov 12, 2019 at 1:21

While all the technical answers are true, I would consider it a bit of an informal warning, that you dished out rights a bit to generously or copying criss+cross... (most often we all do, to get things initially working, eh?)

How to make it blue on black,... ?

A good „de-greener“ to get back to rights you most likely want, is this statement:

chmod -R a-x,o-w,+X thatGreenFolderWithSubfolders/

Best understood what it does, if you understand the purpose of uppercase +X „special execute“, i.e. see Wikipedia

It is only really useful when used with '+' and usually in combination with the -R option for giving group or other access to a big directory tree without setting execute permission on normal files (such as text files), which would normally happen if you just used "chmod -R a+rx...

  • 1
    Does not work on a NTFS filesystem e.g. used for MS Windows.
    – Ingo
    Commented Jul 23, 2021 at 7:20
  • 1
    I was having problems with this in WSL2 mounts, this was the fix, thank you!
    – Sienna
    Commented May 21, 2022 at 17:30

Here are the 3 steps I used to change the colors:

First, copy the default colors to a file

dircolors -p > ~/.dircolors

Then modify this file. You can find some values for colors inside, and here are some more:

Code    Color
0   Default Colour
1   Bold
4   Underlined
5   Flashing Text
7   Reverse Field
31  Red
32  Green
33  Orange
34  Blue
35  Purple
36  Cyan
37  Grey
40  Black Background
41  Red Background
42  Green Background
43  Orange Background
44  Blue Background
45  Purple Background
46  Cyan Background
47  Grey Background
90  Dark Grey
91  Light Red
92  Light Green
93  Yellow
94  Light Blue
95  Light Purple
96  Turquoise
100  Dark Grey Background
101  Light Red Background
102  Light Green Background
103  Yellow Background
104  Light Blue Background
105  Light Purple Background
106  Turquoise Background


And finally, add the following line to your ~/.bashrc file for the colors to be automatically loaded when you open a terminal:

eval 'dircolors ~/.dircolors' > /dev/null

For ~/.zshrc:

if [[ -f ~/.dircolors ]] ; then
    eval $(dircolors -b ~/.dircolors)     
elif [[ -f /etc/DIR_COLORS ]] ; then
    eval $(dircolors -b /etc/DIR_COLORS)
  • works like a charm ! Commented Dec 23, 2021 at 2:36

Well this mean that this folder has permissions if you run this:

chmod og-w AU_LI

it will remove bgcolor :)


To fix this try the ow parameter to the LS_COLORS

For example:

~ls -l

enter image description here

Now you add the ow (OTHER_WRITABLE) option

~export LS_COLORS='fi=0:ln=5:pi=0:so=7:bd=5:cd=5:or=31:mi=0:ex=93:*.py=36:di=40:*.zip=33:*.tgz=33:ow=0'
~ls -l

enter image description here Bamm !!


You can change the tone of green in Putty to make the text readable.

Open Putty and go to Window\Colours, select "ANSI Green", set it to a darker green(R:0 G:70 B:0).


Make all directories the same normal color. Copy/paste this to the end of the file ~/.bashrc

export LS_COLORS+=':tw=01;34:ow=01;34:st=01;34'

Start a new terminal to see the changes


In git-bash / MINGW the folder colors is often an issue for me. I like to use the following command as it makes things obvious:

eval "$(dircolors <(dircolors -p | grep -v '^[.#]' | sed -E '/DIR/s/[0-9;]{5}/01;33/g'))"

You must log in to answer this question.

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