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:
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:
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:
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.
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 |

