Change colors of the ls command in Linux


I would like to change the colors of the ls command in my data partition, since the directories are not very readable from the console.

It's a NTFS partition that I share with Windows and my / etc / fstab file contains the following for the partition:

/dev/sda4 /media/datos ntfs-3g rw,defaults 0 0
asked by akko 27.12.2016 в 03:23

1 answer


To change the color in the terminal, you must modify your .bashrc file.

You enter the terminal:

nano $HOME/.bashrc

You add to the end of the file:

export PS1="\[$(tput setaf 1)\]\[email protected]\h:\w $ \[$(tput sgr0)\]"

Save (control + o) and then close (control + x). Now you upload your file that you just changed.

source ~/.bashrc

List of options:

  • tput bold - bold
  • tput rev - inverted colors
  • tput sgr0 - Reset all
  • tput setaf {CODE} - Set foreground color, see color {CODE}

CODE of colors:

Color {code}    Color
0   Black
1   Red
2   Green
3   Yellow
4   Blue
5   Magenta
6   Cyan
7   White

Another way to change colors is using LS_COLORS:

You enter the terminal:

wget -O $HOME/.dircolors
echo 'eval $(dircolors -b $HOME/.dircolors)' >> $HOME/.bashrc
. $HOME/.bashrc


answered by 27.12.2016 / 03:36