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

Explanation:
FILE-TYPE: file type or directories. sample: jpg (for image file), DIR (for directories)
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

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.

Comments

  1. Vajx0aj says:

    vaj l0n chym en :))

Give me your feedback

This site uses Akismet to reduce spam. Learn how your comment data is processed.