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.


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

  • 5
    BACKGROUND_COLOR codes are not the same as FOREGROUND_COLOR; Background codes are 40-47 – Ryan V. Bissell Oct 21 '15 at 18:55
  • 38;5; starts an xterm 256-color foreground color code. 48;5; starts an xterm 256-color background color code. Cyan in my dircolors output is 38;5;51 not 36 though the result is the same. – stevesliva Feb 7 '18 at 14:50
  • 1
    @stevesliva: Thanks for your comment. I've edited the answer to indicate the background color codes correctly, and describe the 256-color foreground and background color codes. – Thomas Nyman Feb 22 '18 at 9:34

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.

  • 7
    The default colors often seem to indicate the original author hates us and our eyes though... – kurtm Oct 10 '13 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 Mar 26 '15 at 15:42
  • Thanks. Why eval "$(dircolors ~/dircolors)"; instead of more direct way such as dircolors ~/dircolors? – Tim Oct 22 '15 at 15:27
  • @Tim because dircolors only prints the settings, you need to eval it in order for them to be read. – terdon Oct 22 '15 at 15:58
  • for them to be read by whom? – Tim Oct 22 '15 at 16:13

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


I had the same question, terdon's answer is nice but I think there is a confusion between dirname and dircolors ?

Anyway, after some further research I could change the colors, so I'm sharing my solution here. It may be useful for someone some day !

So, 3 simple steps:

First, as terdon said, copy the default colors to a file

dircolors -p > ~/.dircolors

Then modify this file. You can find some values for colors inside, but I found more here :)

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

Voilà :)

  • 1
    for ~/.zshrc I had to go with if [[ -f ~/.dircolors ]] ; then eval $(dircolors -b ~/.dircolors) elif [[ -f /etc/DIR_COLORS ]] ; then eval $(dircolors -b /etc/DIR_COLORS) fi . Sorry line break are aweful – Eric D. Johnson Oct 21 '15 at 16:45

To quickly fix the problem, (make other-writable files yellow on nobg):


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.


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

сhmod og-w AU_LI

it will removes bgcolor :)


To fix this try the ow parameter over the LS_COLORS

For example:

~ls -l

enter image description here

Now you add the ow 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


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).

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.