funwithlinux blog

Redhat Linux: How to Change Directory Color for Your User (Fix Hard-to-See Blue on Black Background)

If you’ve spent time working in a Redhat-based Linux terminal (e.g., RHEL, CentOS, Fedora), you may have noticed a common frustration: the default directory color is often a dark blue. On a black terminal background, this dark blue text can be extremely hard to read—especially in low-light environments or for users with visual impairments.

This isn’t just an aesthetic issue; poor readability slows down workflow and increases eye strain. Fortunately, Linux offers granular control over terminal colors, and changing the directory color for your user account is a simple, permanent fix.

In this guide, we’ll walk through the process step-by-step, from understanding how terminal colors work in Linux to modifying the directory color and making the change stick across sessions. By the end, you’ll have a terminal with directories that are easy to spot and read.

2025-12

Table of Contents#

  1. Understanding Terminal Colors in Linux
  2. Prerequisites
  3. Step-by-Step Guide to Change Directory Color
  4. Troubleshooting Common Issues
  5. Conclusion
  6. References

Understanding Terminal Colors in Linux#

Before diving into changes, let’s briefly explain how terminal colors work in Linux. Most modern terminals use ANSI escape codes to define text colors, styles (e.g., bold), and backgrounds. For the ls command (used to list directory contents), colors are controlled by the LS_COLORS environment variable.

LS_COLORS is a colon-separated list of key-value pairs, where each key defines a file type or attribute, and the value defines its color/style. For directories, the key is di (short for “directory”). The value is an ANSI color code, often prefixed with style modifiers (e.g., 1; for bold).

Example LS_COLORS Entry for Directories#

A typical default entry for directories looks like:

di=34  

Here, di = directory, and 34 is the ANSI code for dark blue (the problematic color we’re fixing).

Prerequisites#

To follow this guide, you’ll need:

  • A Redhat-based Linux system (RHEL, CentOS Stream, Fedora, or Rocky Linux).
  • Access to a terminal (physical or SSH).
  • Basic familiarity with command-line navigation (e.g., cd, ls).
  • Write permissions for your home directory (to modify shell configuration files like .bashrc).

Step-by-Step Guide to Change Directory Color#

Step 1: Identify Your Current Directory Color Setting#

First, let’s confirm the current color code for directories. Run this command in your terminal:

echo $LS_COLORS | grep "di="  

Example Output:

di=34:fi=0:ln=36:pi=33:so=33:bd=33;01:cd=33;01:or=31;01:mi=01;05;37;41:ex=32:*.tar=31:*.tgz=31:...  

The di=34 part tells us directories are currently set to ANSI code 34 (dark blue).

Step 2: Choose a New Directory Color#

Now, pick a new color that’s more readable on a black background. Below is a table of common ANSI color codes (foreground colors) to help you choose:

ANSI CodeColor NameDescriptionReadability on Black Background
30BlackDark (not useful here)Poor
31RedStandard redGood (if not overused)
32GreenStandard greenExcellent
33YellowStandard yellowExcellent
34BlueDark blue (default)Poor (hard to read)
35MagentaPurpleGood
36CyanTeal/light blueGood
37WhiteLight grayGood
90Bright BlackDark grayFair
91Bright RedLight redExcellent
92Bright GreenLight greenExcellent
93Bright YellowLight yellowExcellent
94Bright BlueLight blueGood
95Bright MagentaLight purpleGood
96Bright CyanLight cyan (teal)Best (high contrast)
97Bright WhiteWhiteGood (may be too bright)

Recommendation: Avoid 34 (dark blue). Instead, try 32 (green), 33 (yellow), or 96 (bright cyan)—these are widely considered the most readable on black backgrounds.

Step 3: Test the New Color Temporarily#

Before making permanent changes, test the new color in your current terminal session. Use this command, replacing NEW_CODE with your chosen ANSI code (e.g., 96 for bright cyan):

export LS_COLORS="di=NEW_CODE:$LS_COLORS"  

Example (Bright Cyan):

export LS_COLORS="di=96:$LS_COLORS"  

Now run ls to see the change:

ls  

Directories should now appear in your chosen color. If you don’t like it, try another code (e.g., 32 for green: export LS_COLORS="di=32:$LS_COLORS").

Step 4: Make the Change Permanent#

To retain the new color across terminal sessions and reboots, add the export command to your shell configuration file. Most Redhat users use the bash shell, so we’ll modify .bashrc (in your home directory).

For Bash Users:#

  1. Open .bashrc with a text editor (e.g., nano or vim):

    nano ~/.bashrc  
  2. Scroll to the bottom of the file and add the export command from Step 3. For example, to set bright cyan:

    # Custom directory color (replace 96 with your chosen code)  
    export LS_COLORS="di=96:$LS_COLORS"  
  3. Save and exit:

    • In nano: Press Ctrl+O to save, then Ctrl+X to exit.
    • In vim: Press Esc, type :wq, and press Enter.
  4. Apply the changes immediately by sourcing .bashrc:

    source ~/.bashrc  

For Zsh Users (if you use zsh instead of bash):#

If you use zsh, modify ~/.zshrc instead of ~/.bashrc:

nano ~/.zshrc  

Add the same export line, then source with:

source ~/.zshrc  

Step 5: Verify the New Color#

Open a new terminal window (or run ls again in the current one). Directories should now display in your chosen color. To confirm the change is permanent, log out and log back in—your new color should persist.

Troubleshooting Common Issues#

Issue 1: Changes Don’t Take Effect#

  • Cause: You forgot to source .bashrc or opened a new terminal before sourcing.
  • Fix: Run source ~/.bashrc or close and reopen your terminal.

Issue 2: Color Code Not Working#

  • Cause: Typo in the ANSI code (e.g., 99 instead of 96).
  • Fix: Double-check the ANSI code table above. Use echo $LS_COLORS | grep di= to confirm the di= entry uses your chosen code.

Issue 3: Other File Types Are Affected#

  • Cause: Accidentally overwrote other LS_COLORS entries (e.g., missing :$LS_COLORS in the export command).
  • Fix: Ensure your export line appends to existing LS_COLORS:
    export LS_COLORS="di=96:$LS_COLORS"  # Correct (appends)  
    # NOT: export LS_COLORS="di=96"      # Incorrect (overwrites all other settings)  

Conclusion#

Changing the directory color in Redhat Linux is a simple yet impactful tweak that improves readability and reduces eye strain. By following these steps, you’ve customized LS_COLORS to use a brighter, more visible color for directories—permanently, for your user account.

Experiment with different ANSI codes (e.g., 32 for green or 93 for bright yellow) to find what works best for your eyes. Enjoy your newly readable terminal!

References#