Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

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

It is normally nice to have color output from ls, grep, etc. But when you don't want it (such as in a script where you're piping the results to another command) is there a switch that can turn it off? ls -G turns it on (with BSD-derived versions of ls) if it's not the default, but ls +G does not turn it off. Is there anything else that will?

share|improve this question
Late but for anyone searching: for GNU ls and grep when piping you don't need to do anything because --color=auto already turns off coloring when its output is a pipe, or in fact anything but a tty; that's what 'auto' means. Similarly FreeBSD ls -G or 'CLICOLOR' is 'disabled if the output is not directed to a terminal unless ... CLICOLOR_FORCE ...'. – dave_thompson_085 Jul 19 at 3:13
up vote 30 down vote accepted

Color output for ls is typically enabled through an alias in most distros nowadays.

$ alias ls
alias ls='ls --color=auto'

You can always disable an alias temporarily by prefixing it with a backslash.

$ \ls

Doing the above will short circuit the alias just for this one invocation. You can use it any time you want to disable any alias.

share|improve this answer
You could also use command ls, of course, but this is a little faster. – iconoclast Jan 1 '14 at 19:45

With GNU ls, you can specify ls --color=never to explicitly disable color output. (Even if you have an alias ls='ls --color=auto', when you run ls --color=never, it will expand to ls --color=auto --color=never, and the later option takes precedence.)

share|improve this answer
This is really the answer I was looking for, but I'll keep slm's answer as the chosen one since it handles cases of non-GNU ls, like BSD-derived versions (OS X, Solaris, and of course *BSD). – iconoclast Jan 1 '14 at 16:42

on many derivatives you can also simply use (as on DOS):


it will show the results without color, you can add the arguments same to ls, like -l

share|improve this answer
alias ls=ls


unalias ls

This disables permanently the colorings.

share|improve this answer
Of course this is a bit like killing a fly with a shotgun: you lose all other options you'd added to ls aliases, and you lose them for the whole session, instead of just a single command. – iconoclast Aug 5 '15 at 22:50
That's why i said "permanently" :-) – Slyx Aug 7 '15 at 0:23

To Turn Off the color: unalias ls

To Turn On the color: alias ls='ls --color=auto'

To Temporarily disable the color: \ls -ltr

share|improve this answer

In many *nix distributions this is turned on by default in the users .bashrc.

Edit ~/.bashrc and remove the line that looks like:

alias ls='ls --color=auto'

If you wish to disable this feature for all new accounts generated on this machine in the future, remove the same line from:

share|improve this answer

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.