How to Change Directory Colors in CentOS

When you log in to your dedicated server via SSH and run the ls command to list your files, you may notice that directories and files are color-coded. Directories are probably dark blue along with light blue symbolic links, and bright green executables. For some users, especially those who prefer a dark or even black console background, dark blue directories might just be too dark. Fortunately, the procedure to change them is rather painless.

By default, Red Hat Enterprise Linux, Fedora, and CentOS store directory color information for Bash in /etc/DIR_COLORS, but if you change the information in that file, it will affect all users on the entire server. Instead, simply copy it to the home directory of the user you want to have different colors:

cp /etc/DIR_COLORS ~/.dir_colors


cp /etc/DIR_COLORS /home/[username]/.dir_colors

Next, edit the new file at ~/.dir_colors. Then, find the line that looks like this:

DIR 01;34 # directory

You can change it to whatever color you want. For example, if you want the directories to be yellow, you would change it to:

DIR 01;33 # directory

For a full list of directory colors and other configuration options, see the online manual for dircolors.