Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I recall that eval "dircolors -b" used to display the colours that LS_COLORS was using, based on the file types or extensions. It was not simply the colour values that were displayed but the colours themselves. I could see the colour in which a .png or .ogg file would be displayed and change it if needed through a custom file.

I find that the output of eval "dircolors -b" is no more in colour.

Can someone kindly explain how I might get it back? Perhaps some environment variable is not getting set. Otherwise, is there a workaround?

share|improve this question
I'm not really understanding how eval "dircolors -b" would ever display the output in color. eval doesn't do any handling on the output of the commands. – EightBitTony Oct 23 '12 at 11:02
This is what I recall; I might be wrong. If not that command, then some other similar command allowed me to see the extensions listed in the colours they would display in. That much I remember seeing. The question is what command shows output similar to dircolors but in the respective colours? Sorry for the bother. – chandra Oct 23 '12 at 11:31
@Stéphane Gimenez: Your expansion of abbreviations at that weblink is very helpful. I have three abbreviations, rs, ca, and mh that are not included above. Can you please tell me where to find their expansions? Thanks – chandra Oct 26 '12 at 18:25
up vote 3 down vote accepted

Try this script, but the output might just wired you out ...

(dircolors -b >/dev/null;  # run in a subshell so it won't crash current color settings
 IFS=:; for x in ${LS_COLORS[@]};   # for all colors
     IFS='='; echo -e "\E[${x##*=}m${x%%=*}";  # echo color and extension

enter image description here

share|improve this answer
Thank you. I remember only the file extensions showing up in their respective colours. I need to do some digging up to understand what IFS is though. – chandra Oct 23 '12 at 18:48

This version has some additional information and doesn't color the entire lines:

eval $(echo "no:global default;fi:normal file;di:directory;ln:symbolic link;pi:named pipe;so:socket;do:door;bd:block device;cd:character device;or:orphan symlink;mi:missing file;su:set uid;sg:set gid;tw:sticky other writable;ow:other writable;st:sticky;ex:executable;"|sed -e 's/:/="/g; s/\;/"\n/g')           
   for i in $LS_COLORS     
        echo -e "\e[${i#*=}m$( x=${i%=*}; [ "${!x}" ] && echo "${!x}" || echo "$x" )\e[m" 

Part of answer by @karthick87 on Askubuntu
Also, see this answer: What causes this green background in ls output?

share|improve this answer

Your Answer


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

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