I would like to know how to change the terminal color, so whenever I run ls it will return the name of:

  • Directories in red
  • Files in blue
  • Executable files (those you do ./file) in light green

How do I do that?

2 Answers 2


Usually this is done with

ls -G

Personally I'm using an alias, e.g. in .bash_aliases which is loaded by .bash_profile

alias ls="ls -G"

However, there's another option, i.e. turning on CLICOLOR in your shell, e.g. by adding the following to your .bash_profile

export CLICOLOR=1
  • I would use the "export CLICOLOR=1" version because this may also affect other commands whereas the "alias ls="ls -G" solution will "only" affect ls Commented Mar 24, 2014 at 9:33

See this article "ls, colors, and Terminal.app" to customize the default ls colors.

Basically, what you need to do is change the value of the LSCOLORS variable (default is Gxfxcxdxbxegedabagacad on OS X). Each letter represent a color:

  • a = black
  • b = red
  • c = green
  • d = brown
  • e = blue
  • f = magenta
  • g = cyan
  • h = grey
  • A = dark grey
  • B = bold red
  • C = bold green
  • D = yellow
  • E = bold blue
  • F = magenta
  • G = cyan
  • H = white
  • x = default

And each two-letter group the foreground and background color for a type of entry. For example, the first two letters make your directories being shown as Cyan (G) on a default (x) background (ie. the background color of your term).

The positions are:

  1. directory
  2. symbolic link
  3. socket
  4. pipe
  5. executable
  6. block device
  7. character device
  8. executable with setuid set
  9. executable with setguid set
  10. directory writable by others, with sticky bit
  11. directory writable by others, without sticky bit

So to get the output you asked in your question, setting LSCOLORS to bxfxcxdxcxegedabagacad should do the trick, except for the "normal files" colors, which it seems can't be changed this way.

All credits to Jonathan Dance for the blog post linked earlier, most of this answer is copied from it.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .