Page 1 of 1

ls colors in Linux

Posted: Tue Apr 16, 2013 7:43 pm
by cah
I never liked the colors shown with 'ls' command in Linux.

When I tried to list alias, I found the following:

Code: Select all

alias l.='ls -d .* --color=tty'
alias ll='ls -l --color=tty'
alias ls='ls --color=tty
'
I knew this must be set somewhere in a profile perhaps under /etc.
I then did a search:

Code: Select all

cd /etc
find . -exec grep -l "color=tty" {} \;
Following 2 files caught my attention:

Code: Select all

-rwxr-xr-x 1 root root  766 Mar 14  2012 colorls.csh
-rwxr-xr-x 1 root root  727 Mar 14  2012 colorls.sh
I checked into both files and they are the culprit.

colorls.csh:

Code: Select all

if ( "$color_none" == '' ) then
alias ll 'ls -l --color=tty'
alias l. 'ls -d .* --color=tty'
alias ls 'ls --color=tty'
endif
colorls.sh:

Code: Select all

if ! egrep -qi "^COLOR.*none" $COLORS >/dev/null 2>/dev/null ; then
        alias ll='ls -l --color=tty' 2>/dev/null
        alias l.='ls -d .* --color=tty' 2>/dev/null
        alias ls='ls --color=tty' 2>/dev/null
fi
I made a copy of both files and rename the original files for future reference and removed the --color=tty from them. Restarted the terminal session and all colors disappear as expected.