Tip Details Add a Related Tip

Rate as: Positive Negative

Color coding the ls command in Fedora

When you use the ls command in a terminal, most *nix systems provide for some sort of color coding. You can make the listing results have different colors for the text, background colors, and font styles based on the type of file. If you want to change the color coding used, you can. In Fedora, the color coding is contained in a file called /etc/DIR_COLORS. If you have permissions, you can go edit this file.

From the comments in the file itself, here are the color color and font options available:

# Attribute codes:
#
# 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed
#
# Text color codes:
# 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white
#
# Background color codes:
# 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white

When you edit the file, you'll use the above numeric codes for named file types. You can use more than one code by separating them with semi-colons. Here are some examples:

NORMAL 00       # global default, although everything should be something.
FILE 00         # normal file
DIR 01;34       # directory
LINK 01;36      # symbolic link
FIFO 40;33      # pipe

So in this case, LINK (symbolic link files) will be shown using code 01 (bold text) and code 36 (text color of cyan).

You can also specify the color codes based on the file extension as in these examples:

.cmd 01;32   # executables (bright green)
.tar 01;31   # archives or compressed (bright red)
.jpg 01;35   # image formats (magenta)

By editing this file, you can color code your ls command results to look any way you want. As I mentioned, the file this is contained in for Fedora is /etc/DIR_COLORS. I'm not sure about other Linux/Unix systems, but I suspect they have a similarily named file that allows this type of color configuration too.
Rating: 100% positive, 2 total Votes
Categories: Fedora Linux Unix customization terminal
Added: on Apr 25, 2008 at 8:27 am
Added By: an anonymous user

Comments on this Tip

Add a Comment
There are no comments for this tip
Your Comment:
(how to format)
Rate This Tip:

Verify Humanity:
Sorry, we know it's annoying, but please enter the characters shown in the image to the left so that we know you're an actual person and not an evil spammer. Thanks.
       

Related Tips

Running X11 programs from the terminal

no ratings, 0 comments
– Tip added by an anonymous user on Jan 28, 2008 at 8:04 am

ssh and scp without passwords

Categories: shell Mac linux UNIX
100% positive, 1 comment - last added on Jun 20, 2008 at 9:19 am
– Tip added by an anonymous user on Dec 21, 2007 at 2:51 pm

Fedora update kills log rolling

Categories: Fedora linux repair bugs
100% positive, 1 comment - last added on Feb 29, 2008 at 7:39 am
– Tip added by an anonymous user on Feb 28, 2008 at 7:29 am

Software Development Automation with Scripting Languages

Categories: linux unix scripting
no ratings, 0 comments
– Tip added by an anonymous user on Jun 05, 2008 at 2:40 pm

Adding programs to the iBar in gOS

Categories: gOS linux customization
no ratings, 0 comments
– Tip added by an anonymous user on Feb 03, 2008 at 12:17 pm

Changing an already running job to execute in the background

Categories: linux UNIX Mac
no ratings, 0 comments
– Tip added by an anonymous user on Aug 06, 2007 at 11:57 am

Update your shell prompt

Categories: UNIX Mac linux shell
no ratings, 0 comments
– Tip added by an anonymous user on Jun 04, 2007 at 9:15 pm

Arranging RSS feeds in Google Reader

Categories: google RSS customization
100% positive, 0 comments
– Tip added by an anonymous user on Jun 21, 2008 at 3:28 pm

Remove Spotlight icon from manu bar

100% positive, 0 comments
– Tip added by an anonymous user 4 days, 8 hours ago

Adding searches to the Finder sidebar

100% positive, 0 comments
– Tip added by an anonymous user on Jun 27, 2008 at 9:07 am

Change the carrier name on your iPhone

50% positive, 0 comments
– Tip added by an anonymous user on Jun 25, 2008 at 1:34 pm

Reduce the back button size in Firefox 3

Categories: firefox customization
100% positive, 0 comments
– Tip added by foxnut on Jun 20, 2008 at 7:51 am

Increasing layer thumbnail images sizes in Photoshop

100% positive, 0 comments
– Tip added by flortin on Jun 19, 2008 at 9:35 am

Adding Opera speed dials

100% positive, 0 comments
– Tip added by an anonymous user on Jun 19, 2008 at 8:33 am

Turn off Vista notification balloons

100% positive, 0 comments
– Tip added by an anonymous user on Jun 16, 2008 at 7:54 am

Using GMail in Firefox for mail links

100% positive, 0 comments
– Tip added by an anonymous user on Jun 13, 2008 at 8:26 am

Aperture loupe style

no ratings, 0 comments
– Tip added by an anonymous user 3 days, 8 hours ago

Safer windows registry editing

no ratings, 0 comments
– Tip added by an anonymous user on Jun 27, 2008 at 11:00 am

managing blackberry icons

no ratings, 0 comments
– Tip added by an anonymous user on Jun 24, 2008 at 1:03 pm

Selecting parts of words in MS Word

no ratings, 0 comments
– Tip added by an anonymous user on Jun 16, 2008 at 4:45 pm