changing colors of files/dirs in linux ls

I use putty with a black background and was wondering if there was or is a way to change the colors of the dirs which are dark blue.

i noticed DIR_COLORS.xterm and DIR_COLORS

do they play this role?


Solution 1:

It depends on the version of Linux your using, for example on Ubuntu you edit the Bash File while on others you edit the DIR_COLORS.

CentOS/RHEL/Fedora

Step 1 - Copy the DIR_COLORS to your home folder or skip this for all accounts.

cp /etc/DIR_COLORS ~/.dir_colors

Step 2 - Edit the DIR_COLORS (If you copied it to your home folder, otherwise just vi dir_colors

vi ~/.dir_colors

Step 3 - Find

DIR 01;34     # directory

Step 4 - Replace with (Change the 33 with the color you want)

DIR 01;33     # directory

You may need to do this in the Xterm file as well, but generally that is more local.

Ubuntu

Step 1 - Ubuntu Backup the Bash File First

sudo cp .bashrc .bashrc-backup

Step 2 - Then nano the Bashrc File

sudo nano .bashrc

More help for Ubuntu users can be found here.

http://help.ubuntu.com/community/CustomizingBashPrompt

Solution 2:

PuTTY uses its own colour specs for emulating X terminals. It is under the Window -> Colours category in the main configuration window you get on startup. In the section 'Adjust the precise colours PuTTY displays' you can edit entries in the 'Select a colour to adjust' box. The usual directory colour, for example, is ANSI blue. I find this too dark, so I lighten it to (74,74,255).

To enable colours in a standard bash session under most distros (and certainly Debian-like things such as Ubuntu,) first test for the existence of the dircolors executable, then look for a local override .dircolors. If found, run dircolors with the local file and if not use the system defaults.

if [ -x /usr/bin/dircolors ]; then
   test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
fi

The -b flag means emit Bourne shell compatible colourisation rules. To alter the colours themselves, you will need to provide an X11 resource file with the overrides you want. Put this in ~/.Xresources and add lines like *xterm*color12: #1e90ff. This will get merged into your X resource database on next login. You will need to experiment to see which colour gets mapped to which file type.