How To Wiki

How to set the colors displayed with the ls command

1,797pages on
this wiki
Add New Page
Talk0 Share

the output of the ls command can be colorized for different file types including symbolic links, directories, and executables.

  1. Edit:
    • /etc/DIR_COLORS
    • for local user ~/.dir_colors
  2. add the line
    • COLOR [option]
    • where [option] can be none tty or all
  3. add line for your terminal program:
    • TERM [type]
    • where [type] is xterm, aterm, eterm, or what ever your terminal is

Seting colorsEdit

Below are the color init strings for the basic file types. A color init string consists of one or more of the following numeric codes:

  • 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

NORMAL 00 # global default, although everything should be something.
FILE 00 # normal file
DIR 01;37 # directory
LINK 01;36 # symbolic link. (If you set this to 'target' instead of a
                   # numerical value, the color will match the file pointed to)
FIFO 40;33 # pipe
SOCK 01;35 # socket
DOOR 01;35 # door
BLK 40;33;01 # block device driver
CHR 40;33;01 # character device driver
ORPHAN 01;05;37;41 # orphaned syminks
MISSING 01;05;37;41 # ... and the files they point to

This is for files with execute permission:

EXEC 01;32

List any file extensions like '.gz' or '.tar' that you would like ls to colorize below. Put the extension, a space, and the color init string. (and any comments you want to add after a '#')

.cmd 01;32 # executables (bright green) .exe 01;32 .com 01;32 .btm 01;32 .bat 01;32 .sh 01;32 .csh 01;32

using colorsEdit


  • ls --color

For ls to display in color( --color=tty ) is applicable

Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.