Get rid of color ‘ls’ output in Linux

Color ls outputMany popular varieties of Linux use a “feature” which causes the ls command output to show files, directories, links, etc. all in different colors. I guess some people prefer this, but I find it at best annoying, and at worst illegible. Specifically the color-coding of symbolic links tend to show in such a light color that it is often impossible to read.

The color output is accomplished by adding the --color=tty or a similar option to the ls command. This is typically accomplished by creating an alias to ls in either the user’s profile or in one of the system-wide profiles.

alias ls='ls --color=tty'

My personal preference is to remove this line from any system-wide configuration files (such as /etc/profile) and allow users to set it in their own profile if preferred. If you don’t have the desire or ability to make this change universally than a user can easily disable the color output by using the unalias command:

unalias ls

This can either be added to the user’s configuration file (e.g. the .profile or .bash_profile in their home directory), or you can just type unalias ls anytime to disable color ls output for the rest of the current shell session. This can be especially useful to turn off the color output when you’re working on someone else’s system.

Color-coded ls output can cause permissions errors in some circumstances, so in my opinion it is best left off, but if you’re stuck with it then it’s nice to know how it can be disabled when necessary.

ls, sysadmin, system administration, linux, shell, bash, sh, UNIX

11 thoughts on “Get rid of color ‘ls’ output in Linux”

  1. Can you describe what you mean when you say “Color-coded ls output can cause permissions errors in some circumstances”? In what way would the output of ls cause permissions problems?

  2. I was wondering exactly the same as Cloned Milkmen. During my 11 years of using Linux I have never come across such an issue.

  3. In CentOS, if you copy the file /etc/DIR_COLORS to your home directory as ~/.dir_colors, and if you change the line with “COLOR tty” to “COLOR none”, then all your login sessions become color-free.

    Was looking for a solution to this color mess. I can’t bear bright colors due to eye problems. Hence, the desperate need to de-colorify the terminal o/p.

  4. I execute “unalias ls” in my profile. ls is aliased to “ls –color=tty”. That takes care of the color issue.

    The reason why I don’t use the color is that I have problems with my vision and need high contrast like white on black. So, on a color listing, I can’t see the dark blue against a black background.

    Jack

  5. Color is great but not in plain terminal environments. We use a terminal emulator that defaults to blue backgrounds and the Linux color “ls” ends up setting the default text color to blue– so we get blue on blue and can’t read anything. Color “ls” makes bogus assumptions about what kind of terminal you are using and how it is configured, and is generally distracting. And don’t get me started on the color “vim” enhancements– they set new standards of annoyance, especially since figuring out all the settings you have to turn off can be quite a challenge:

    syntax off
    let g:loaded_matchparen=1
    set nocp
    set noincsearch
    set nohlsearch
    set noshowmatch

  6. Thank you. I just installed Ubuntu 8.04.1 and it was extremely annoying. Defaulted to light pastels on a white background, and worse, for some directories it was dark green text on a slightly darker green background making it literally illegible. If the defaults were sane colors I could have lived with them, but I have better things to do with my time than editing color codes for ls.

  7. why to bother about alias. just type simple command – dir. it doesn’t display color. it function same like ls but without colors.

    it works for me. some system doesn’t support that.

  8. just put

    unalias -a
    ksh or zsh & set -o vi & export EDITOR=vi into your login rc file and you’ll end up with a non-broken working environment.

    most of the time i’m also too lazy to set this up though. but it’s really not worth your time to work around all these little details each and every day, rather get rid of them from the start.

    It will cost you a few of those “clever” features and you’ll have a 5% lower risk of cardial arrest.

Leave a Reply

Your email address will not be published. Required fields are marked *