# Understanding the Core Files
$ ls -l /etc/DIR_COLORS*
-rw-r--r-- 1 root root 4433 Apr 5 2018 /etc/DIR_COLORS
-rw-r--r-- 1 root root 4339 Apr 5 2018 /etc/DIR_COLORS.xterm
Linux terminal colors for ls
command are controlled through these mechanisms:
- System-wide:
/etc/DIR_COLORS
(generic) and/etc/DIR_COLORS.xterm
(terminal-specific) - User-specific:
~/.dir_colors
(overrides system settings)
For PuTTY with black background, modify the dark blue directory entry:
# Backup original file
$ cp /etc/DIR_COLORS ~/.dir_colors
# Edit the configuration
$ nano ~/.dir_colors
# Change this line (original):
DIR 01;34 # directory
# To one of these alternatives:
DIR 01;36 # cyan
DIR 01;33 # yellow
DIR 01;35 # magenta
Different terminals may need different configurations:
# For xterm-type terminals
TERM xterm
DIR 01;36
# For rxvt-type terminals
TERM rxvt
DIR 01;33;47
After modifying the configuration:
# Load new settings
$ eval $(dircolors ~/.dir_colors)
# Test immediately
$ ls
To make changes permanent, add this to your ~/.bashrc
:
# Persistent dircolors configuration
if [ -f ~/.dir_colors ]; then
eval "$(dircolors ~/.dir_colors)"
fi
Full syntax for color definitions:
# Format: TYPE ATTRIBUTES;FOREGROUND;BACKGROUND
# Example for executable files:
EXEC 01;32 # bright green
Common attributes (first number):
00
= none01
= bold04
= underlined05
= flashing07
= reverse
For quick temporary changes:
# Set directly in terminal
$ export LS_COLORS="di=1;36:ex=1;32:*.txt=1;33"
This changes directories to cyan, executables to green, and text files to yellow.
# Check current LS_COLORS value
$ echo $LS_COLORS
# Verify terminal type
$ echo $TERM
# Reload bash configuration
$ source ~/.bashrc
When using Putty with a black background, the default dark blue directory colors in ls
output become nearly unreadable. This isn't just a Putty issue - many terminal emulators and dark themes face similar visibility challenges with the default Linux color scheme.
The system uses two key files for color configuration:
/etc/DIR_COLORS # System-wide defaults
~/.dir_colors # User-specific overrides
For Xterm-based terminals (including Putty), the system may also reference:
/etc/DIR_COLORS.xterm
First, copy the default configuration to your home directory:
cp /etc/DIR_COLORS ~/.dir_colors
Then edit the file to modify the problematic entries. The key lines to change:
DIR 01;34 # Change from dark blue (34) to something more visible
For dark backgrounds, these alternatives work well:
DIR 01;36 # Cyan
DIR 01;33 # Yellow
DIR 01;35 # Magenta
DIR 01;32 # Green
After saving the file, either:
- Start a new terminal session, or
- Run:
eval $(dircolors ~/.dir_colors)
For Putty, you might also need to:
- Configure ANSI colors in Putty's settings
- Ensure "Use system colours" is unchecked
- Adjust individual color values in Window → Colours
If colors don't change as expected:
# Verify file parsing
dircolors --print-database ~/.dir_colors
# Check environment variables
echo $LS_COLORS
Add this to your ~/.bashrc
:
if [ -f ~/.dir_colors ]; then
eval $(dircolors ~/.dir_colors)
fi
Here's a sample .dir_colors
for dark terminals:
# Avoid dark blue and black
DIR 01;36
LINK 01;35
SOCK 01;33
FIFO 01;33
EXEC 01;32
# File types
.txt 00;32
.md 00;32
.conf 00;33