The Computer Oracle

How to make `ls` color its output by default, without setting up an alias?

Become or hire the top 3% of the developers on Toptal https://topt.al/25cXVn

--

Music by Eric Matyas
https://www.soundimage.org
Track title: Digital Sunset Looping

--

Chapters
00:00 Question
00:49 Accepted answer (Score 97)
01:20 Answer 2 (Score 0)
01:46 Thank you

--

Full question
https://superuser.com/questions/665274/h...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#linux #ls #xterm

#avk47



ACCEPTED ANSWER

Score 107


There is no way: the ls man page will show you that the default setting (for --color) is 'none' - ie. never use colour.

Any reason you don't want to use aliases? I'm a recovering Red Hat user, so every time I install a new distribution I set three ls aliases like so:

## Colorize the ls output ##
alias ls='ls --color=auto'

## Use a long listing format ##
alias ll='ls -la'

## Show hidden files ##
alias l.='ls -d .* --color=auto'



ANSWER 2

Score 0


You can use the alias method so that every time you open the terminal and use ls (verbatim just ls , not ls --color), results will be coloured. You can add the alias to your .bashrc, for example, as the following command line:

alias ls='ls --color=auto'