It's been a lot of years since colors were first introduced on the command line of Unix/Linux systems. But, yes, there was a time when terminal windows were simply black and white. Today, file names might show up in a number of different shades -- green, red, blue, purple/magenta, or some other color -- depending on the type of file (whether they are executable files, directories, images, etc.) or the file extensions. Sometimes you might just want to turn the colors off because they're distracting you from what you want to pay attention to. At other times, they help you to instantly identify important file characteristics. In any case, there's a lot that you can do to control the colors that are used and what they're used for.
Where do the colors come from?
On many systems, it all begins with a file named DIR_COLORS. Check for /etc/DIR_COLORS on your system and you might see some of the settings that give birth to the colors you see when you list your files.
$ head /etc/DIR_COLORS # Configuration file for the color ls utility # Synchronized with coreutils 8.5 dircolors # This file goes in the /etc directory, and must be world readable. # You can copy this file to .dir_colors in your $HOME directory to override # the system defaults.
You can also look to see how the $LS_COLORS variable is configured in your account.
If that all looks like a pile of mumbo jumbo, take a deep breath. Notice that it's full of settings separated by colons. And each colon-separated entry is is setting some value to either a number of a set of numbers separated by semi-colons. The numbers provide some visual function based on their ranges.
The first and most obvious range is the settings for the text colors. The numbers 30 through 37 represent the basic range of colors you can use.
These are the basic colors. The range 30-37 represents the basic colors. There are also some additional colors and other numeric ranges that represent different character settings. The image above is a screen capture, so the colors should be close to what you would see.
The settings shown below are for three separate image files types. All have the same settings -- 01 and 35. The 35 will make the text purple (magenta). The 01 supposedly makes the font bold, but seems to not have any effect. What this section tells us is that all of these image types will look the same in a file listing.
Some of the other settings are for other effects -- like underlining -- and some work as expected.
Effects 00 Default color 01 Bold 04 Underlined 05 Flashing text 07 Reversed 08 Concealed
Here's what some files using these settings look like on my screen. The underlined and reversed settings look just right.
The extra color range gives you an additional eight colors. The range 90-97 provides these. So, here are all the colors with a medium gray background so that you can see the white and black.
There's also a range for background colors. Most of these seem to work as expected.
File name colors, when used to display the things you care about are great. But one simple rule for coloring the text in your terminal windows is "if everything stands out, nothing stands out". Used excessively, colors and effects can be more annoying than useful.
This article is published as part of the IDG Contributor Network. Want to Join?