Changing directory color of ls command

For some unknown reason, the default color for directories printed by ls is blue, which reads badly on a black background.

The default colors for ls can be changed via the environment variable LS_COLORS. To try it out, open a terminal and type in the following commands:

ls -la # possibly with --color option
export LS_COLORS='di=0;35'
ls -la

You should see a difference between the two executions of ls (if you have directories in the current folder). To make these changes permanent, add them to your bash initialization script (e.g., ~/.bashrc, ~/.bash_profile, ~/.bash_login).

The strange string 0;35 is a so-called color code and it conforms to ISO 6429 as described in the man page of dir_colors. The second number is the color (35 = magenta) and the first number modifies the ‘value/darkness’ of the color.

The man page lists some more colors: 44 = blue, 46 = cyan, etc.

If you want to know about which color is assigned to a specific file type, you may print out the whole dircolors database by typing:

dircolors --print-database

An output in the appropriate format for LS_COLORS (e.g., for the Bash) can be retrieved by typing:

dircolors --bourne-shell # or simply: -b


  • My first hit when searching for more information was this blog post
  • Here is an online version of the dir_colors man page.

Leave a Reply