Where is color of ls command defined?

1) Configuration file for the ls color command is /etc/DIR_COLORS for Linux. You can modify those colours if you want.

2) Here is list of most common colors: (RHEL 3.x/FCx/RH and other linux distros)
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 syminks : 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)

3) They are stored in special shell variable called LS_COLORS

4) You can customized them in /etc/DIR_COLORS or file pointed by shell variable COLORS.

5) To customized colors you must use special string combination:
FILE-TYPE Attribute codes: Text color codes:Background color codes


  • FILE-TYPE: is file type like 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

For example to define Bold Blue color for DIR file type, entry should look as follows:
DIR 01;34

6) Let us modify dir color on Red Hat (Fedora) Linux:

# vi /etc/DIR_COLORS

Modify DIR entry

DIR 01;34 # default is Bold blue with black background


DIR 01;34;41 # NEW default is Bold blue with RED background

Save file.

7) Logout and login again, Please note that if you have shell variable defined COLORS then use that file (use echo $COLORS to find it out).

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 8 comments so far... add one
CategoryList of Unix and Linux commands
Disk space analyzersncdu pydf
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
8 comments… add one
  • Anonymous Mar 3, 2006 @ 19:52

    It’s not necessary to log in and out. Just run ‘eval `dircolors -b /etc/DIR_COLORS`’ (note the backticks)

    flisespikker.no (norwegian+some english)

  • Anonymous Oct 17, 2006 @ 16:49

    is it possible to temporarily disable colours? sometimes I just want white on black 🙂

  • AdamD Jan 26, 2007 @ 17:36

    > ..disable colored ls

    On RH, to enable colored ls, an alias is created ‘ls -> ls –color=tty’ SO … “/bin/ls” will display without colors

  • nana Apr 16, 2009 @ 9:11

    i want to know how to open green color type of file?

  • marsigliese Nov 26, 2009 @ 17:21

    green color usually is for executable files
    in LS_COLORS=”…..:ex=00;32:..”
    ex is not a file extension
    it is an ls attribute

    you can execute theese files typing:
    ./file if you are in the same directory

    maybe you have some file type setted to 00;32
    so if you want to know if it is executable type
    ls -l

    -rwxr–r– 1 root root 18380 9 feb 2009 file
    … | |
    owner group
    you can see 3 “rwx” positions
    the first refers to the user owner of the file
    the second to the group of the file
    the third to all the users

    you need the x (eXecutable) correspondent to your user (w writable, r readable)
    if you can you can change it with chmod
    chmod 777 file
    chmod u+x
    a) {u,g,o} user,group,others
    b) +,- 1,0
    c) {r,w,x}

    omiting a) you intend ugo+x
    omitting b) you intend u+rwx (i don’t know if does it works)

  • Dave Beaumont May 4, 2011 @ 19:31

    Type: unalias ls
    everything will be white

    • Michael Mar 31, 2017 @ 16:32

      After you unalias ls, if you want to turn the ls colors back on, you can enter this command:
      alias ls=’ls –color=auto’

  • Vivek Kumar Nov 11, 2013 @ 9:20

    I don’t have access to /etc folder. How can I do the same for user account by which I have logged in?

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum