Beginners Guide: Change ls command Text Color

One thing i like from Linux is it have full customization. You can change your text color on your command line. And especially for “ls” command. ls command is to list information about the files or directory in Linux CLI (Command Line Interface). ls command is one of the most frequent use command in Linux CLI.

The result of the ls command will have text color to make different of files type, directory, symbolic links and etc. And in some Linux distro have different color than others. And sometimes they have same default color for all. So it is hard to find the difference between directories and files.

To change ls command text color you can find it in /etc/DIR_COLORS. You can edit it with vim:

vim /etc/DIR_COLORS

Default colors for Ubuntu or CentOS:
* 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)

The file will store in this following format:
FILE-TYPE Attribute_codes: Text_color_codes:Background_color_codes

FILE-TYPE: file type or directories. sample: jpg (for image file), DIR (for directories)
* 00=none
* 01=bold
* 04=underscore
* 05=blink
* 07=reverse
* 08=concealed
* 30=black
* 31=red
* 32=green
* 33=yellow
* 34=blue
* 35=magenta
* 36=cyan
* 37=white
* 40=black
* 41=red
* 42=green
* 43=yellow
* 44=blue
* 45=magenta
* 46=cyan
* 47=white

Sample command:
DIR 01;34
Will make directories will bold and yellow text.

Customize it until you meed your favorite color.  Save it and restart your session. It will change the color.

Article by Vijay Nayani

  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: