How to set colors for ls command in linux

color setup for ls

How to set colors for ls command in linux

LS_COLORS is an bash environment variable to set the color of the files listed in bash environment with ls command.

for current LS_COLORS variable definition, you can see with echo command

 echo $LS_COLORS

You need to define LS_COLORS variable with various colors for various files and export that variable.

'dircolors' is a command to generate the default color scheme LS_COLORS variable.

so using 'dircolors' you can generate the default color scheme, then you need to add that variable definition to your bashrc file.

Go to your home directory in your terminal, with the help of dircolors command you can generate LS_COLORS

Now you need to define and export the variable LS_COLORS, Here we are going with default color scheme that is generated with dircolors command.

dircolors -b >> .bashrc

with out the above command, you can manually add the out put of 'dircolors' to you .bashrc file which is present in your home directory.

You can alter the LS_COLORS definition as you like by editing the color code in LS_COLORS variable you defined in .bashrc file.

To apply setting to your bash environment run this command.

source ~/.bashrc