About nixCraft

Topics

Where is color of ls command defined?

Posted by Vivek Gite [Last updated: December 1, 2004]

1) Configuration file for the ls color command is /etc/DIR_COLORS for Linux. You can modify those colours if you want.

2) Here is list of most common colors: (RHEL 3.x/FCx/RH and other linux distros)
Executable files: Green
* Normal file : Normal
* Directory: Blue
* Symbolic link : Cyan
* Pipe: Yellow
* Socket: Magenta
* Block device driver: Bold yellow foreground, with black background
* Character device driver: Bold yellow foreground, with black background
* Orphaned syminks : Blinking Bold white with red background
* Missing links ( - and the files they point to) : Blinking Bold white with red background
* Archives or compressed : Red (.tar, .gz, .zip, .rpm)
* Image files : Magenta (.jpg, gif, bmp, png, tif)

3) They are stored in special shell variable called LS_COLORS

4) You can customized them in /etc/DIR_COLORS or file pointed by shell variable COLORS.

5) To customized colors you must use special string combination:
FILE-TYPE Attribute codes: Text color codes:Background color codes

Where,

For example to define Bold Blue color for DIR file type, entry should look as follows:
DIR 01;34

6) Let us modify dir color on Red Hat (Fedora) Linux:

# vi /etc/DIR_COLORS

Modify DIR entry
From:

DIR 01;34 # default is Bold blue with black background

To:

DIR 01;34;41 # NEW default is Bold blue with RED background

Save file.

7) Logout and login again, Please note that if you have shell variable defined COLORS then use that file (use echo $COLORS to find it out).

E-mail this to a Friend    Printable Version

You may also be interested in other helpful articles:

Discussion on This Article:

  1. Anonymous Says:

    It’s not necessary to log in and out. Just run ‘eval `dircolors -b /etc/DIR_COLORS`’ (note the backticks)

    flisespikker.no (norwegian+some english)

  2. Anonymous Says:

    is it possible to temporarily disable colours? sometimes I just want white on black :)

  3. AdamD Says:

    > ..disable colored ls

    On RH, to enable colored ls, an alias is created ‘ls -> ls –color=tty’ SO … “/bin/ls” will display without colors

Leave a Reply

We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Thank you very much for stopping by our site!

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Copyright © 2004-2008 nixCraft. All rights reserved - TOS/Disclaimer - Privacy policy - Powered by Open source software.