1

I'm using CentOS 6.5 and Putty. My problem is that directory file names are shown in dark blue color which is hard to read. I google searched and found this link; basically it's copying the DIR_COLORS file from /etc to the home directory so changes will only affect the user instead of everyone. The real problem is that whenever I run this command cp /etc/DIR_COLORS ~/.dir_colors, no .dir_colors file is created. And there is no error message too. I ran it using sudo too but also no file is created.

When I named the file dir_colors(without the dot) then the file will be created, but when I changed the color from 1;34 to 1;33 in DIR # directory, the dark blue color doesn't change to the new color. I'm guessing it is because the dot is missing before the file name. Any ideas why no file is created when I used .dir_colors?

  • 3
    Since you created a file starting with a dot, make sure you did ls -al to see if it's there... – user44370 Mar 13 '14 at 19:37
0

Once the file is copied as per the instructions, just do cd to make sure you're in your home directory, then name_of_your_text_editor .dir_colors and edit the file all you want, and save it. Restart your terminal to see the results.

If for some reason you can't find the .dir_colors file, you could always use whatever file you want that contains the color definition you want like so:

eval `dircolors yourcolorfile`

Effect is immediate on your next ls. This won't persist across sessions so you could add that line to your .bashrc file and achieve the same result as having the .dir_colors file in your home directory. Usage is not limited to CentOS

  • Thanks, it seems that the file named .dir_colors was created. But because I was using the command ls instead of ls -al, it was not showing when I was in my home directory. The text dark blue color was changed successfully. No more eyes-ache. Thanks a lot everyone! – Voltic Mar 13 '14 at 20:36
  • You're welcome... the day you need some change, try maybe this one. Cheers! – user44370 Mar 13 '14 at 20:42
  • Just out of curiosity, will you explain a little bit more how can I do it using the .bashrc file? What line should I add to this file? – Voltic Mar 13 '14 at 20:53
  • You just add the line starting with eval to your .bashrc file in your home dir. Make sure to replace "yourcolorfile" by the full path and name of the file i.e. /home/myuser/mycolorfile. Also, make sure to use those backticks and not quotes. Then you would issue source .bashrc and that would work. But replacing or copying the user .dir_colors is more convenient than having to add something to bashrc etc. But it's quite useful to test such and such a color file on the command line... – user44370 Mar 13 '14 at 21:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.