SnipIT No 7: Change colour when using “ls”

SnipIT is a series of short blogs containing useful information in an easily digestible format.
Listing the files and directories in a PuTTY session when connected to Red Hat recently, I realised how bad the contrast is between the default dark blue on black.
To change this to something more usable, we can edit the bashrc file.

$ vi ~/.bashrc

With the file open in vi, press “i” to enter insert mode and move to the end of the document.
Add the following line:

LS_COLORS=$LS_COLORS:'di=0;37:'; export LS_COLORS

Press “:” and then “wq” to write the changes, if you want to quit the file without saving the changes then press “:” and “q!”.
For the changes to take affect in the current session, type:

$ source ~/.bashrc

Let’s try that out with a “ls -al”
That’s much better!
if you prefer a different colour then you can substitute “37” for another value, the “0” is a switch between standard and bold (“1”).






Leave a Reply

Your email address will not be published. Required fields are marked *