dir_colors(5)

๐Ÿ’– dir_colors(5) โ€” the file format manual, bestie edition ๐Ÿ’–

okay so listen. this is dir_colors, section 5 of the File Formats Manual, and it's literally just the configuration file for dircolors(1). that's the whole vibe. let's get into it ๐ŸŽ€


โœจ NAME โœจ

dir_colors โ€” configuration file for dircolors(1) ๐Ÿฆ‹


๐ŸŒธ DESCRIPTION ๐ŸŒธ

so here's the tea: ls(1) looks at the environment variable LS_COLORS to figure out what colors to paint your filenames in. and that variable? usually set by a command like this one, bestie:

eval `dircolors some_path/dir_colors`

you'll find that line chilling in a system default shell initialization file, like /etc/profile or /etc/csh.cshrc. (also go read dircolors(1) while you're at it ๐Ÿ’…) usually the file used here is /etc/DIR_COLORS, and you can override it with a .dir_colors file in your home directory. main character energy, honestly.

this config file is made of several statements, one per line. anything to the right of a hash mark (#) counts as a comment โ€” but ONLY if the hash mark is at the very beginning of a line or has at least one whitespace before it. blank lines get ignored, no notes. ๐Ÿ™ˆ

the global section of the file is any statement before the first TERM statement. anything in the global section is valid for all terminal types. after the global section comes one or more terminal-specific sections, each introduced by one or more TERM statements that say which terminal types (as given by the TERM environment variable) the following declarations apply to. and get this โ€” you can always override a global declaration with a later terminal-specific one. slay. ๐Ÿ‘‘

the following statements are recognized; case is insignificant:

  • TERM terminal-type โ€” starts a terminal-specific section and says which terminal it applies to. you can stack multiple TERM statements to make a section that applies to several terminal types at once.
  • COLOR yes|all|no|none|tty โ€” (Slackware only; ignored by GNU dircolors(1).) says colorization should always be on (yes or all), never on (no or none), or on only when the output is a terminal (tty). the default is no.
  • EIGHTBIT yes|no โ€” (Slackware only; ignored by GNU dircolors(1).) says eight-bit ISO/IEC 8859 characters should be enabled by default. for compatibility reasons you can also write it as 1 for yes or 0 for no. the default is no.
  • OPTIONS options โ€” (Slackware only; ignored by GNU dircolors(1).) adds command-line options to the default ls command line. the options can be any valid ls command-line options, and should include the leading minus sign. heads up: dircolors does not verify that these options are valid. ๐Ÿ’€
  • NORMAL color-sequence โ€” the color used for normal (nonfilename) text. synonym: NORM.
  • FILE color-sequence โ€” the color used for a regular file.
  • DIR color-sequence โ€” the color used for directories.
  • LINK color-sequence โ€” the color used for a symbolic link. synonyms: LNK, SYMLINK.
  • ORPHAN color-sequence โ€” the color used for an orphaned symbolic link (one that points to a nonexistent file). if you don't specify this, ls just uses the LINK color instead.
  • MISSING color-sequence โ€” the color used for a missing file (a nonexistent file that nevertheless has a symbolic link pointing to it). if you don't specify this, ls uses the FILE color instead.
  • FIFO color-sequence โ€” the color used for a FIFO (named pipe). synonym: PIPE.
  • SOCK color-sequence โ€” the color used for a socket.
  • DOOR color-sequence โ€” (supported since fileutils 4.1) the color used for a door (Solaris 2.5 and later).
  • BLK color-sequence โ€” the color used for a block device special file. synonym: BLOCK.
  • CHR color-sequence โ€” the color used for a character device special file. synonym: CHAR.
  • EXEC color-sequence โ€” the color used for a file with the executable attribute set.
  • SUID color-sequence โ€” the color used for a file with the set-user-ID attribute set. synonym: SETUID.
  • SGID color-sequence โ€” the color used for a file with the set-group-ID attribute set. synonym: SETGID.
  • STICKY color-sequence โ€” the color used for a directory with the sticky attribute set.
  • STICKY_OTHER_WRITABLE color-sequence โ€” the color used for an other-writable directory with the executable attribute set. synonym: OWT.
  • OTHER_WRITABLE color-sequence โ€” the color used for an other-writable directory without the executable attribute set. synonym: OWR.
  • LEFTCODE color-sequence โ€” the left code for non-ISO/IEC 6429 terminals (see below). synonym: LEFT.
  • RIGHTCODE color-sequence โ€” the right code for non-ISO/IEC 6429 terminals (see below). synonym: RIGHT.
  • ENDCODE color-sequence โ€” the end code for non-ISO/IEC 6429 terminals (see below). synonym: END.
  • *extension color-sequence โ€” the color used for any file that ends in extension.
  • .extension color-sequence โ€” same as *.extension. the color used for any file that ends in .extension. note: the period is included in the extension, which makes it impossible to specify an extension that doesn't start with a period, like ~ for emacs backup files. this form should be considered obsolete. ๐Ÿซ 

๐ŸŒˆ ISO/IEC 6429 (ANSI) color sequences ๐ŸŒˆ

most color-capable ASCII terminals these days use ISO/IEC 6429 (ANSI) color sequences, and lots of common terminals without color capability โ€” including xterm and the widely used and cloned DEC VT100 โ€” will recognize ISO/IEC 6429 color codes and harmlessly strip them out of the output, or emulate them. ls uses ISO/IEC 6429 codes by default, assuming colorization is enabled. โœจ

ISO/IEC 6429 color sequences are built from sequences of numbers separated by semicolons. the most common codes are:

  • 0 โ€” to restore default color
  • 1 โ€” for brighter colors
  • 4 โ€” for underlined text
  • 5 โ€” for flashing text
  • 30 โ€” for black foreground
  • 31 โ€” for red foreground
  • 32 โ€” for green foreground
  • 33 โ€” for yellow (or brown) foreground
  • 34 โ€” for blue foreground
  • 35 โ€” for purple foreground
  • 36 โ€” for cyan foreground
  • 37 โ€” for white (or gray) foreground
  • 40 โ€” for black background
  • 41 โ€” for red background
  • 42 โ€” for green background
  • 43 โ€” for yellow (or brown) background
  • 44 โ€” for blue background
  • 45 โ€” for purple background
  • 46 โ€” for cyan background
  • 47 โ€” for white (or gray) background

not all commands will work on all systems or display devices. no cap. ๐Ÿ˜ญ

ls uses the following defaults:

  • NORMAL โ€” 0 โ€” Normal (nonfilename) text
  • FILE โ€” 0 โ€” Regular file
  • DIR โ€” 32 โ€” Directory
  • LINK โ€” 36 โ€” Symbolic link
  • ORPHAN โ€” undefined โ€” Orphaned symbolic link
  • MISSING โ€” undefined โ€” Missing file
  • FIFO โ€” 31 โ€” Named pipe (FIFO)
  • SOCK โ€” 33 โ€” Socket
  • BLK โ€” 44;37 โ€” Block device
  • CHR โ€” 44;37 โ€” Character device
  • EXEC โ€” 35 โ€” Executable file

a few terminal programs don't recognize the default properly. if literally all your text gets colorized after you do a directory listing, change the NORMAL and FILE codes to the numerical codes for your normal foreground and background colors. easy fix, we love that for you. ๐Ÿ’–


๐Ÿงš Other terminal types (advanced configuration) ๐Ÿงš

if you've got a color-capable (or otherwise highlighting) terminal (or printer!) that uses a different set of codes, you can still generate a suitable setup. to do that, you'll have to use the LEFTCODE, RIGHTCODE, and ENDCODE definitions.

when writing out a filename, ls generates the following output sequence:

LEFTCODE typecode RIGHTCODE filename ENDCODE

where typecode is the color sequence that depends on the type or name of the file. if ENDCODE is undefined, the sequence LEFTCODE NORMAL RIGHTCODE gets used instead. the whole point of the left- and rightcodes is just to cut down on how much typing you have to do (and to hide ugly escape codes away from the user). if they're not appropriate for your terminal, you can eliminate them by specifying the respective keyword on a line by itself.

NOTE: if ENDCODE is defined in the global section of the setup file, it can't be undefined in a terminal-specific section of the file. this means any NORMAL definition will have no effect. a different ENDCODE can, however, be specified, which would have the same effect. ๐Ÿ”ฅ

๐ŸŽ€ Escape sequences ๐ŸŽ€

to specify control- or blank characters in the color sequences or filename extensions, you can use either C-style \-escaped notation or stty-style ^-notation. the C-style notation includes the following characters:

  • \a โ€” Bell (ASCII 7)
  • \b โ€” Backspace (ASCII 8)
  • \e โ€” Escape (ASCII 27)
  • \f โ€” Form feed (ASCII 12)
  • \n โ€” Newline (ASCII 10)
  • \r โ€” Carriage Return (ASCII 13)
  • \t โ€” Tab (ASCII 9)
  • \v โ€” Vertical Tab (ASCII 11)
  • \? โ€” Delete (ASCII 127)
  • \nnn โ€” Any character (octal notation)
  • \xnnn โ€” Any character (hexadecimal notation)
  • \_ โ€” Space
  • \\ โ€” Backslash (\)
  • \^ โ€” Caret (^)
  • \# โ€” Hash mark (#)

note that escapes are necessary to enter a space, backslash, caret, or any control character anywhere in the string, as well as a hash mark as the first character. so likeโ€ฆ don't forget them. ๐Ÿ™ˆ


๐Ÿ“ FILES ๐Ÿ“

  • /etc/DIR_COLORS โ€” System-wide configuration file.
  • ~/.dir_colors โ€” Per-user configuration file.

this page describes the dir_colors file format as used in the fileutils-4.1 package; other versions may differ slightly.


๐Ÿ’œ NOTES ๐Ÿ’œ

the default LEFTCODE and RIGHTCODE definitions, which are used by ISO/IEC 6429 terminals, are:

LEFTCODE    \e[
RIGHTCODE   m

the default ENDCODE is undefined.


โญ SEE ALSO โญ

dircolors(1), ls(1), stty(1), xterm(1)


okay that's the whole page!! this was Linux man-pages 6.20, dated 2026-02-08 โ€” go forth and colorize your terminal, bestie, you're gonna eat ๐Ÿ’…โœจ๐Ÿฆ‹

๐Ÿ“ฆ where this page comes from
  • arch rolling: man-pages 6.20-1 ยท BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
  • nixpkgs unstable: man-pages 6.20
  • ๐Ÿ“œ the page's license: GPL-2.0-or-later
  • ๐Ÿ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms