Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I do use aliases to turn on color for some commands by default. But I'm wondering if there's an easier way at telling my system, color is supported, don't make me use --color for grep, ls, etc.

share|improve this question
up vote 8 down vote accepted


On Linux and any other system with GNU tools, you need to set LS_COLORS, GREP_COLOR, and GREP_OPTIONS='--color=auto', but even then you still need to run ls --color=auto. Run info coreutils 'ls invocation' for more details.

The easiest way I know to avoid typing --color on Linux is to make ls run ls --color=auto using an alias.

This is what I put in my .bashrc (well, really my .env, but it's like .bashrc) to make it happen by default:

# set default flags
if grep --color=auto --quiet "" "$HOME"/.bashrc >/dev/null 2>&1
  alias grep='grep --color=auto'
if ls --color=never --directory / >/dev/null 2>&1
  # enable colors with GNU ls
  alias ls='ls --color=auto'
  alias ls='ls -F'
share|improve this answer
GNU fails in this regard – xenoterracide Jan 18 '11 at 4:34

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.