From ls' man page:
Code:
--color[=WHEN]
colorize the output; WHEN can be 'always' (default if omitted),
'auto', or 'never'; more info below
(...)
Using color to distinguish file types is disabled both by default and
with --color=never. With --color=auto, ls emits color codes only when
standard output is connected to a terminal. The LS_COLORS environment
variable can change the settings. Use the dircolors command to set it.
When you create your user during Ubuntu install, you get a number of aliases automatically:
Code:
$ alias
(...)
alias ls='ls --color=auto'
So by default, ls runs with --color=auto, which will show colours when your use it directly on a terminal, but not when redirecting the output to a file, a pipe to a different tool or to ssh. You can change this by changing the alias, but then it will also use colours when writing to a file and there are tools that may be broken by such behaviour.