One thing I like about Linux is its full customization. You can change your text color in the command line, and especially for the ls command. The ls command lists information about files or directories in the Linux CLI (Command Line Interface). It is one of the most frequently used commands in Linux CLI.
The result of the ls command uses text color to differentiate file types, directories, symbolic links, etc. Some Linux distributions have different colors than others, and sometimes they have the same default color for all file types, making it hard to tell the difference between directories and files.
To change ls command text color you can find the configuration 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 symlinks: 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 uses the following format:
FILE-TYPE Attribute_codes:Text_color_codes:Background_color_codes
Explanation:
FILE-TYPE: file type or directory. Example: jpg (for image files), 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 display with bold and yellow text.
Customize it until you meet your favorite color. Save it and restart your session. It will change the color.
