Changing terminal colors in Ubuntu Server

You'll need to configure your LS_COLORS export in your ~/.dir_colors (system wide at /etc/dir_colors)

See here for documentation: http://manpages.ubuntu.com/manpages/karmic/man5/dir_colors.5.html

::EDIT::

To make it stick:

  1. append this to your ~/.bashrc
    if [ "$TERM" != "dumb" ]; then
      [ -e "$HOME/.dir_colors" ] && 
      DIR_COLORS="$HOME/.dir_colors" [ -e "$DIR_COLORS" ] ||
      DIR_COLORS="" 
      eval "`dircolors -b $DIR_COLORS`" 
      alias ls='ls --color=auto'
    fi
  1. create/edit your ~/.dir_colors,

    for example with dircolors --print-database > .dir_colors

  2. Then force a read of your .bashrc file with:

    $: source ~/.bashrc

  3. Everything should be pretty.


How to change the colors of file listings in Linux shells

Summary

Linux interactive terminals (aka ssh terminal, konsole or console login) automatically choose colors for 'files', 'directories', 'hard links', 'soft links', 'pipes', 'sockets', 'filesystems', etc. You see these colors displayed when you type 'ls' to list file contents. Directories are usually blue, files are usually light grey. Different foreground/background colors are used for various kinds of filesystem objects.

Problem:

Your terminal displays directory links as dark blue when you type 'ls', and you want it to be light cyan so you can read it better.

Solution

Using your favorite editor, open this file: /etc/DIR_COLORS You should see something like this:

#NORMAL 00      # no color code at all
#FILE 00        # regular file: use no color at all
RESET 0         # reset to "normal" color
DIR 01;34       # directory
LINK 01;36      # symbolic link.  (If you set this to 'target' instead of a
                # numerical value, the color is as for the file pointed to.)
MULTIHARDLINK 00        # regular file with more than one link
FIFO 40;33      # pipe
SOCK 01;35      # socket
DOOR 01;35      # door
BLK 40;33;01    # block device driver
CHR 40;33;01    # character device driver
ORPHAN 01;05;37;41  # orphaned syminks
MISSING 01;05;37;41 # ... and the files they point to
SETUID 37;41    # file that is setuid (u+s)
SETGID 30;43    # file that is setgid (g+s)
CAPABILITY 30;41        # file with capability
STICKY_OTHER_WRITABLE 30;42 # dir that is sticky and other-writable (+t,o+w)
OTHER_WRITABLE 34;42 # dir that is other-writable (o+w) and not sticky
STICKY 37;44    # dir with the sticky bit set (+t) and not other-writable

Notice the 4th line down starting with: "DIR". That is the color for your Directory links. If you want more info about what the codes mean visit this site:

http://tldp.org/HOWTO/Bash-Prompt-HOWTO/x329.html

Notice the code for DIR is '01;34'. the 34 means dark blue. You may be tempted to just edit this file /etc/DIR_COLORS right where it sits. DON'T do that. Because then you'll be changing the colors for EVERYONE who logs into this computer. You'll have to make a copy of this in your own directory so only your login is affected.

How to change the directory colors for your user

Copy /etc/DIR_COLORS into your home directory with this command:

cp /etc/DIR_COLORS /home/yourusername/.dir_colors

Open up your /home/yourusername/.dir_colors in your favorite editor and edit the line that looks like this:

DIR 01;34       # directory

And change it to this;

DIR 01;36       # directory

34 is the code for blue, 36 is the code for cyan. Save the /home/yourusername/.dir_colors You'll have to logout/login for the settings to take effect. (sourcing your profiles won't suck in the changes). Once you logout/login, run the command 'ls'. The directories should show up with cyan instead of blue. Like this:

Before:

enter image description here

After:

enter image description here