Use of colors for indicating different types of files and directories can be enabled for the ls command. This is useful to discern the files you want from the output quickly.
To enable color output use the
--coloroption. To be more clever and show colors only when the output is not being piped to another program, use the
By default, these colors are used: blue for directories, cyan for symbolic links, green for executables, yellow for device files, red for archived files and pink for image files.
You can see the color settings for the various file types and extensions by running the
echo $LS_COLORS. Both of them should show the same output.
The explanation of the various foreground and background color values as set in
$LS_COLORSare explained here.
To set your own colors or add new filetypes with colors, change the
$LS_COLORSenvironment variable in your shell startup file.
Once you have colors, you may find the character indicators that ls uses by default as unnecessary. You can turn them off by using the