Sign up ×
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.

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

5 Answers 5

up vote 21 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
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 at 22:50
That's why i said "permanently" :-) – Slyx Aug 7 at 0:23

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

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

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.