dircolors
Configure color settings for directory listings
TLDR
Output commands to set $LS_COLOR using default colors
Display each filetype with the color they would appear in ls
Output commands to set $LS_COLOR using colors from a file
Output commands for Bourne shell
Output commands for C shell
View the default colors for file types and extensions
SYNOPSIS
dircolors [OPTION]... [FILE]
PARAMETERS
-b, --bourne-shell
output Bourne/POSIX shell code (sh/bash)
-c, --csh
output C shell code (csh/tcsh)
-p, --print-database
print default color database to stdout
-h, --help
display this help and exit
-V, --version
output version information and exit
DESCRIPTION
dircolors generates shell commands to set the LS_COLORS environment variable, enabling colorized output in ls and compatible tools like grep --color. Colors differentiate file types: directories (blue), executables (green), symlinks (cyan), archives (red), and extensions (e.g., .pdf=magenta).
Without a custom file, it uses a built-in database. Create ~/.dircolors for personalization using ANSI escape codes (e.g., 01;34 for bold blue). Format includes TERM for terminal types, file slots (DIR, FIFO), wildcards (*.tar=01;31), and options (OPTIONS=rb for read-only bold).
Invoke with shell-specific output: -b for bash/sh, -c for csh/tcsh. Source via eval "$(dircolors)" or add to ~/.bashrc. Supports 8/16/256-color terminals; ineffective without color-aware apps or --color=auto in ls.
Enhances CLI usability, reduces misreads in cluttered dirs. Print defaults with -p to bootstrap custom files.
CAVEATS
Output must be eval'd or sourced to set LS_COLORS.
Requires color-supporting terminal and ls --color.
No FILE uses built-in defaults; malformed FILE ignored.
TYPICAL USAGE
eval "$(dircolors -b)"
Or eval "$(dircolors -b ~/.dircolors)" in ~/.bashrc.
DATABASE SNIPPET
TERM linux
DIR 01;34
EXEC 01;32
*.gz=01;31
Use dircolors -p > ~/.dircolors to start.
HISTORY
Introduced in GNU fileutils 3.12 (1994); merged into coreutils 4.5 (1998). Evolved with 256-color support in coreutils 6.11 (2008).


