Accidently make ls colors (folders, files, links...) to white

enter image description hereI accidentally delete/change LS colors when listing directories with the 'ls' command, so I tried the command "ls --color=auto" it works temporarily because when I reboot my terminal ls colors return to just white.


Solution 1:

By default, your ~/.bashrc contains a section that defines the ls and grep commands to run in color mode.

The default .bashrc configuration file can be found in the directory /etc/skel, and from here you can take the relevant section and add it back to your ~/.bashrc to restore the default behavior with color support:

# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]
then
    test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
    alias ls='ls --color=auto'
    alias dir='dir --color=auto'
    alias vdir='vdir --color=auto'

    alias grep='grep --color=auto'
    alias fgrep='fgrep --color=auto'
    alias egrep='egrep --color=auto'
fi

Solution 2:

I'm not sure exactly how Ubuntu works with the default bash alias definitions.

Usually, in your "~/.bashrc" file, you have a source command of "/etc/bashrc". There are many default parameters in this file. And this file load "/etc/profile.d/*" files who contains aliases definitions.

So, do you have modified (accidently) your "~/.bashrc" file or your "~/.bash_profile" ? The last one usually source "~/.bashrc".

If you are non interrested to load default system files (in "/etc"), you cloud add the alias definition "alias ls 'ls --color=auto'" in your own "~/.bashrc".