I'm running CentOS in Linux text mode. When I run the command ls /usr/, the output is too hard to read (dark blue on black). How can I change the text coloring?

Screenshot of the ls output

4 Answers 4


If you are wanting to change your colours in the console, that is outside X, then you can specify colours in your .bashrc, like so:

if [ "$TERM" = "linux" ]; then
    echo -en "\e]P0222222" #black
    echo -en "\e]P8222222" #darkgrey
    echo -en "\e]P1803232" #darkred

Where you are defining black as #222222 See this post for the details: http://phraktured.net/linux-console-colors.html

If you are working in X, then you can customize your setup by defining your colours in your .Xresources like so:

 *color0:  #3D3D3D
 *color8:  #5E5E5E
 *color1:  #8C4665
 *color9:  #BF4D80

and then sourcing this file when you start X, typically from your .xinitrc:

xrdb -merge ~/.Xresources

The Arch Wiki has a page on .Xresources that explains all of the options: https://wiki.archlinux.org/index.php/Xresources

Another enhancement you can make either in X or not is to specify all of the different filetypes that you would like to colour—and their respective colours in a .dir_colors file, like so:

.xinitrc       01;31 
.Xauthority    01;31
.Xmodmap       00;31
.Xresources    01;33

To get started, copy /etc/dir_colors to your user's /home directory and make your changes. Then source this from your .bashrc with eval $(dircolors -b ~/.dir_colors) This will allow you fine-grained control over the colours of files and filetypes when you use ls.

You can find (an incredibly detailed and thorough) .dir_colors example file here: https://github.com/trapd00r/LS_COLORS/blob/master/LS_COLORS

With a combination of all three approaches, you can create a reasonably uniform setup, whether you are working in the console or in X.

  • i am sorry, i am a new learner of linux. i installed it in linux text. there is no console. all the thing are running in command line. thank you, Commented Aug 23, 2011 at 3:43
  • 2
    Yes: that is what I meant when I said outside X - in the TTY consoles (TTY 1-7).
    – jasonwryan
    Commented Aug 23, 2011 at 3:48
  • jasonwryan,i run the command vim /etc/DIR_COLORS the DIR is 01;34 HOW TO CHANGE TO teal color. thank you, Commented Aug 23, 2011 at 6:46
  • 2
    The term colours are here: tldp.org/HOWTO/Bash-Prompt-HOWTO/x329.html Green is 00;32 and light/bold green is 1;32 The only way to get teal is to use the method I described above to define one of those 16 colours as a hex equivalent of teal.
    – jasonwryan
    Commented Aug 23, 2011 at 6:55
  • sorry if this is a beginners question, but does your answer change for a Unix system in OS X? Commented Jun 16, 2014 at 1:19

The file you want is /etc/DIR_COLORS. I had the exact same issue as you and changed directories to a teal color. Works much nicer.

cp /etc/DIR_COLORS /home/yourusername/.dir_colors

Edit /home/yourusername/.dir_colors, you will see this line:

DIR 01;34    #directory

Change that to this:

DIR 01;36    #directory

Which makes directory colors teal.

  • when i run the command /etc/DIR_COLORS it output permission denied. i am the root user, why? how to change the color to teal. thank you Commented Aug 23, 2011 at 3:41
  • 3
    @run It's not a command, it's a configuration file; open it in a text editor Commented Aug 23, 2011 at 3:59
  • the DIR is 01;34 HOW TO CHANGE TO teal color. thank you, Commented Aug 23, 2011 at 4:55
  • @MaxMackie This does not seem to work for me (copied to ~/.dir_colors) and changed everything to 00. Found that I have to open a new terminal. How is this enforced/attached to the current terminal?
    – Bernhard
    Commented Feb 24, 2014 at 16:02

You can set ls colors manually but I prefer this approach:

First of all there is the



dircolors --print-database > ~/.dir_colors

change the colors inside that file (it is quite self explanatory, and the colors are visualized inside the file)
apply the changes:

eval $(dircolors ~/.dir_colors)

for persistent use put this in ~./bashrc:

if [ -f ${HOME}/.dir_colors ]; then
  eval $(dircolors ~/.dir_colors)

Using the ls --color=no flag is the most direct option. A shorter version is ls --col=n.

Piping ls sets --color=no automatically. ls | cat or ls | tee will work.

Also possible, ls | grep ., which makes all output red by default, or ls | grep '' which makes all output white by default.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .