How do I change the color for directories with ls in the console?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP








up vote
126
down vote

favorite
90












On my console the color for directories is such a blue, that it is hard to read on a dark background.



How can I change the color definitions for ls?










share|improve this question



























    up vote
    126
    down vote

    favorite
    90












    On my console the color for directories is such a blue, that it is hard to read on a dark background.



    How can I change the color definitions for ls?










    share|improve this question

























      up vote
      126
      down vote

      favorite
      90









      up vote
      126
      down vote

      favorite
      90






      90





      On my console the color for directories is such a blue, that it is hard to read on a dark background.



      How can I change the color definitions for ls?










      share|improve this question















      On my console the color for directories is such a blue, that it is hard to read on a dark background.



      How can I change the color definitions for ls?







      colors console ls






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Feb 27 '15 at 1:33

























      asked May 15 '14 at 7:27









      rubo77

      13.6k2692188




      13.6k2692188




















          6 Answers
          6






          active

          oldest

          votes

















          up vote
          193
          down vote



          accepted










          To change your directory colors, open up your ~/.bashrc file with your editor



          nano ~/.bashrc


          and make the following entry at the end of the file:



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


          Some nice color choices (in this case 0;35 it is purple) are:



          Blue = 34
          Green = 32
          Light Green = 1;32
          Cyan = 36
          Red = 31
          Purple = 35
          Brown = 33
          Yellow = 1;33
          Bold White = 1;37
          Light Grey = 0;37
          Black = 30
          Dark Grey= 1;30


          The first number is the style (1=bold), followed by a semicolon, and then the actual number of the color, possible styles (effects) are:



          0 = default colour
          1 = bold
          4 = underlined
          5 = flashing text (disabled on some terminals)
          7 = reverse field (exchange foreground and background color)
          8 = concealed (invisible)


          The possible backgrounds:



          40 = black background
          41 = red background
          42 = green background
          43 = orange background
          44 = blue background
          45 = purple background
          46 = cyan background
          47 = grey background
          100 = dark grey background
          101 = light red background
          102 = light green background
          103 = yellow background
          104 = light blue background
          105 = light purple background
          106 = turquoise background
          107 = white background


          All possible colors:



          31 = red
          32 = green
          33 = orange
          34 = blue
          35 = purple
          36 = cyan
          37 = grey
          90 = dark grey
          91 = light red
          92 = light green
          93 = yellow
          94 = light blue
          95 = light purple
          96 = turquoise
          97 = white


          These can even be combined, so that a parameter like:



          di=1;4;31;42


          in your LS_COLORS variable would make directories appear in bold underlined red text with a green background!



          To test all these colors and styles in your terminal, you can use one of:



          for i in 002..8 03,4,9,100..7
          do echo -e "$i e[0;$imSubdermatoglyphic texte[00m e[1;$imSubdermatoglyphic texte[00m"
          done

          for i in 002..8 03,4,9,100..7
          do for j in 0 1
          do echo -e "$j;$i e[$j;$imSubdermatoglyphic texte[00m"
          done
          done


          You can also change other kinds of files when using the ls command by defining each kind with:



          bd = (BLOCK, BLK) Block device (buffered) special file
          cd = (CHAR, CHR) Character device (unbuffered) special file
          di = (DIR) Directory
          do = (DOOR) [Door][1]
          ex = (EXEC) Executable file (ie. has 'x' set in permissions)
          fi = (FILE) Normal file
          ln = (SYMLINK, LINK, LNK) Symbolic link. If you set this to ‘target’ instead of a numerical value, the color is as for the file pointed to.
          mi = (MISSING) Non-existent file pointed to by a symbolic link (visible when you type ls -l)
          no = (NORMAL, NORM) Normal (non-filename) text. Global default, although everything should be something
          or = (ORPHAN) Symbolic link pointing to an orphaned non-existent file
          ow = (OTHER_WRITABLE) Directory that is other-writable (o+w) and not sticky
          pi = (FIFO, PIPE) Named pipe (fifo file)
          sg = (SETGID) File that is setgid (g+s)
          so = (SOCK) Socket file
          st = (STICKY) Directory with the sticky bit set (+t) and not other-writable
          su = (SETUID) File that is setuid (u+s)
          tw = (STICKY_OTHER_WRITABLE) Directory that is sticky and other-writable (+t,o+w)
          *.extension = Every file using this extension e.g. *.rpm = files with the ending .rpm


          A more complete list is available at Bigsoft - Configuring LS_COLORS.



          On some distributions, you might also want to change the background color for ow "(OTHER_WRITABLE) whose default is non-readable" for example to non-bold blue text on green background.



          You could use for instance LS_COLORS="$LS_COLORS:di=1;33" at the end of your .bashrc file, to get a nice readable bold orange text on black background.



          After you alter your .bashrc file, to put the changes in effect you will have to restart your shell or run source ~/.bashrc.



          Note: You can combine more commands with a colon, for example



          LS_COLORS=$LS_COLORS:'di=1;33:ln=36' ; export LS_COLORS; ls


          Source:



          • COLORS Lscolors - Linux StepByStep

          • Geek Gumbo - Changing the Directory Color in Bash





          share|improve this answer


















          • 2




            This works well, thanks. I personally found it better to set LS_COLORS=$LS_COLORS:'di=1;44:' ; export LS_COLORS which shows the directories in bold white over blue background.
            – isapir
            Mar 18 '16 at 18:52






          • 1




            This doesn't seem to work for me. It looks like there is another config file somewhere that overwrites .bashrc - some colors work, others look differently. Folders are green for instance instead of blue, but files look correctly. What could it be?
            – Nearoo
            Jul 9 '16 at 8:42










          • check if you are using bash or sh, and also check your .profile file in your home directory. and global /etc/bash.bashrc
            – rubo77
            Jul 9 '16 at 9:52






          • 4




            You probably want to modify other writable and sticky other writable dirs. Try something more like LS_COLORS=$LS_COLORS:'tw=01;35:ow=01;35:' ; export LS_COLORS
            – Charles L.
            May 25 '17 at 19:57






          • 1




            that worked for ls, but how do i change the color of the dir I am in, before the # in the cmd prompt?
            – Gaia
            Jan 3 at 6:00

















          up vote
          26
          down vote













          Very simple.
          Add these three lines to ~/.bashrc



          $ vi ~/.bashrc
          export LS_OPTIONS='--color=auto'
          eval "$(dircolors -b)"
          alias ls='ls $LS_OPTIONS'


          If you want to apply the changes in a running bash session, run:



          source ~/.bashrc





          share|improve this answer


















          • 3




            This is the only thing that worked for me.
            – solalito
            Jan 29 '17 at 7:54

















          up vote
          3
          down vote













          LS_COLORS



          This is a collection of extension:color mappings, suitable to use as your LS COLORS environment variable.






          share|improve this answer




















          • interesting but I can't make this work in ksh.
            – Herman Toothrot
            Aug 17 '16 at 12:50

















          up vote
          2
          down vote













          Further to Hegazi's answer, you can actually control the directory colour, and a lot of other colours using the dircolors command. You can create a configuration file which is well documented.



          You can create a .dircolor file in your home directory as follows:



          dircolors -p > ~/.dircolors


          Then in your ~/.bashrc file add the lines



          eval "`dircolors -b ~/.dircolors`"
          alias ls='ls --color=auto'


          This will create a $LS_COLORS variable for bash. The -c flag will set if for csh. It also flags the ls command to display in colour.



          Edit the value of the DIR attribute as above in the ~/.dircolor file colour to change the colour of the directory (or any of the other included file types for other colours).
          You can also change the colours of specific files, or define your own.






          share|improve this answer



























            up vote
            0
            down vote













            The is my approach for ls command with commonly used options:



            add the following lines into a file called ~/.alias



            alias ll='ls -lhF --color=auto'
            alias llt='ls -lht --color=auto'
            alias lla='ls -alF --color=auto'
            alias la='ls -A --color=auto'
            alias l='ls -CF --color=auto'
            alias ls="ls --color=auto"


            add the following lines into ~/.bashrc



            if [ -f ~/.alias ]; then
            . ~/.alias
            fi





            share|improve this answer
















            • 1




              you only need to add --color=auto to the ls alias - the other aliases with inherit the setting
              – Stuart Cardall
              Oct 25 '17 at 16:22

















            up vote
            0
            down vote













            The --color=auto option doesn't work for me using iTerm2 on my Mac. The -G option works though. I put the following alias in my ~/.profile and now directories are colored and have a trailing / appended:



            alias ls='ls -F -G'





            share|improve this answer




















              Your Answer







              StackExchange.ready(function()
              var channelOptions =
              tags: "".split(" "),
              id: "89"
              ;
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function()
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled)
              StackExchange.using("snippets", function()
              createEditor();
              );

              else
              createEditor();

              );

              function createEditor()
              StackExchange.prepareEditor(
              heartbeatType: 'answer',
              convertImagesToLinks: true,
              noModals: false,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: 10,
              bindNavPrevention: true,
              postfix: "",
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              );



              );













               

              draft saved


              draft discarded


















              StackExchange.ready(
              function ()
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f466198%2fhow-do-i-change-the-color-for-directories-with-ls-in-the-console%23new-answer', 'question_page');

              );

              Post as a guest






























              6 Answers
              6






              active

              oldest

              votes








              6 Answers
              6






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes








              up vote
              193
              down vote



              accepted










              To change your directory colors, open up your ~/.bashrc file with your editor



              nano ~/.bashrc


              and make the following entry at the end of the file:



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


              Some nice color choices (in this case 0;35 it is purple) are:



              Blue = 34
              Green = 32
              Light Green = 1;32
              Cyan = 36
              Red = 31
              Purple = 35
              Brown = 33
              Yellow = 1;33
              Bold White = 1;37
              Light Grey = 0;37
              Black = 30
              Dark Grey= 1;30


              The first number is the style (1=bold), followed by a semicolon, and then the actual number of the color, possible styles (effects) are:



              0 = default colour
              1 = bold
              4 = underlined
              5 = flashing text (disabled on some terminals)
              7 = reverse field (exchange foreground and background color)
              8 = concealed (invisible)


              The possible backgrounds:



              40 = black background
              41 = red background
              42 = green background
              43 = orange background
              44 = blue background
              45 = purple background
              46 = cyan background
              47 = grey background
              100 = dark grey background
              101 = light red background
              102 = light green background
              103 = yellow background
              104 = light blue background
              105 = light purple background
              106 = turquoise background
              107 = white background


              All possible colors:



              31 = red
              32 = green
              33 = orange
              34 = blue
              35 = purple
              36 = cyan
              37 = grey
              90 = dark grey
              91 = light red
              92 = light green
              93 = yellow
              94 = light blue
              95 = light purple
              96 = turquoise
              97 = white


              These can even be combined, so that a parameter like:



              di=1;4;31;42


              in your LS_COLORS variable would make directories appear in bold underlined red text with a green background!



              To test all these colors and styles in your terminal, you can use one of:



              for i in 002..8 03,4,9,100..7
              do echo -e "$i e[0;$imSubdermatoglyphic texte[00m e[1;$imSubdermatoglyphic texte[00m"
              done

              for i in 002..8 03,4,9,100..7
              do for j in 0 1
              do echo -e "$j;$i e[$j;$imSubdermatoglyphic texte[00m"
              done
              done


              You can also change other kinds of files when using the ls command by defining each kind with:



              bd = (BLOCK, BLK) Block device (buffered) special file
              cd = (CHAR, CHR) Character device (unbuffered) special file
              di = (DIR) Directory
              do = (DOOR) [Door][1]
              ex = (EXEC) Executable file (ie. has 'x' set in permissions)
              fi = (FILE) Normal file
              ln = (SYMLINK, LINK, LNK) Symbolic link. If you set this to ‘target’ instead of a numerical value, the color is as for the file pointed to.
              mi = (MISSING) Non-existent file pointed to by a symbolic link (visible when you type ls -l)
              no = (NORMAL, NORM) Normal (non-filename) text. Global default, although everything should be something
              or = (ORPHAN) Symbolic link pointing to an orphaned non-existent file
              ow = (OTHER_WRITABLE) Directory that is other-writable (o+w) and not sticky
              pi = (FIFO, PIPE) Named pipe (fifo file)
              sg = (SETGID) File that is setgid (g+s)
              so = (SOCK) Socket file
              st = (STICKY) Directory with the sticky bit set (+t) and not other-writable
              su = (SETUID) File that is setuid (u+s)
              tw = (STICKY_OTHER_WRITABLE) Directory that is sticky and other-writable (+t,o+w)
              *.extension = Every file using this extension e.g. *.rpm = files with the ending .rpm


              A more complete list is available at Bigsoft - Configuring LS_COLORS.



              On some distributions, you might also want to change the background color for ow "(OTHER_WRITABLE) whose default is non-readable" for example to non-bold blue text on green background.



              You could use for instance LS_COLORS="$LS_COLORS:di=1;33" at the end of your .bashrc file, to get a nice readable bold orange text on black background.



              After you alter your .bashrc file, to put the changes in effect you will have to restart your shell or run source ~/.bashrc.



              Note: You can combine more commands with a colon, for example



              LS_COLORS=$LS_COLORS:'di=1;33:ln=36' ; export LS_COLORS; ls


              Source:



              • COLORS Lscolors - Linux StepByStep

              • Geek Gumbo - Changing the Directory Color in Bash





              share|improve this answer


















              • 2




                This works well, thanks. I personally found it better to set LS_COLORS=$LS_COLORS:'di=1;44:' ; export LS_COLORS which shows the directories in bold white over blue background.
                – isapir
                Mar 18 '16 at 18:52






              • 1




                This doesn't seem to work for me. It looks like there is another config file somewhere that overwrites .bashrc - some colors work, others look differently. Folders are green for instance instead of blue, but files look correctly. What could it be?
                – Nearoo
                Jul 9 '16 at 8:42










              • check if you are using bash or sh, and also check your .profile file in your home directory. and global /etc/bash.bashrc
                – rubo77
                Jul 9 '16 at 9:52






              • 4




                You probably want to modify other writable and sticky other writable dirs. Try something more like LS_COLORS=$LS_COLORS:'tw=01;35:ow=01;35:' ; export LS_COLORS
                – Charles L.
                May 25 '17 at 19:57






              • 1




                that worked for ls, but how do i change the color of the dir I am in, before the # in the cmd prompt?
                – Gaia
                Jan 3 at 6:00














              up vote
              193
              down vote



              accepted










              To change your directory colors, open up your ~/.bashrc file with your editor



              nano ~/.bashrc


              and make the following entry at the end of the file:



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


              Some nice color choices (in this case 0;35 it is purple) are:



              Blue = 34
              Green = 32
              Light Green = 1;32
              Cyan = 36
              Red = 31
              Purple = 35
              Brown = 33
              Yellow = 1;33
              Bold White = 1;37
              Light Grey = 0;37
              Black = 30
              Dark Grey= 1;30


              The first number is the style (1=bold), followed by a semicolon, and then the actual number of the color, possible styles (effects) are:



              0 = default colour
              1 = bold
              4 = underlined
              5 = flashing text (disabled on some terminals)
              7 = reverse field (exchange foreground and background color)
              8 = concealed (invisible)


              The possible backgrounds:



              40 = black background
              41 = red background
              42 = green background
              43 = orange background
              44 = blue background
              45 = purple background
              46 = cyan background
              47 = grey background
              100 = dark grey background
              101 = light red background
              102 = light green background
              103 = yellow background
              104 = light blue background
              105 = light purple background
              106 = turquoise background
              107 = white background


              All possible colors:



              31 = red
              32 = green
              33 = orange
              34 = blue
              35 = purple
              36 = cyan
              37 = grey
              90 = dark grey
              91 = light red
              92 = light green
              93 = yellow
              94 = light blue
              95 = light purple
              96 = turquoise
              97 = white


              These can even be combined, so that a parameter like:



              di=1;4;31;42


              in your LS_COLORS variable would make directories appear in bold underlined red text with a green background!



              To test all these colors and styles in your terminal, you can use one of:



              for i in 002..8 03,4,9,100..7
              do echo -e "$i e[0;$imSubdermatoglyphic texte[00m e[1;$imSubdermatoglyphic texte[00m"
              done

              for i in 002..8 03,4,9,100..7
              do for j in 0 1
              do echo -e "$j;$i e[$j;$imSubdermatoglyphic texte[00m"
              done
              done


              You can also change other kinds of files when using the ls command by defining each kind with:



              bd = (BLOCK, BLK) Block device (buffered) special file
              cd = (CHAR, CHR) Character device (unbuffered) special file
              di = (DIR) Directory
              do = (DOOR) [Door][1]
              ex = (EXEC) Executable file (ie. has 'x' set in permissions)
              fi = (FILE) Normal file
              ln = (SYMLINK, LINK, LNK) Symbolic link. If you set this to ‘target’ instead of a numerical value, the color is as for the file pointed to.
              mi = (MISSING) Non-existent file pointed to by a symbolic link (visible when you type ls -l)
              no = (NORMAL, NORM) Normal (non-filename) text. Global default, although everything should be something
              or = (ORPHAN) Symbolic link pointing to an orphaned non-existent file
              ow = (OTHER_WRITABLE) Directory that is other-writable (o+w) and not sticky
              pi = (FIFO, PIPE) Named pipe (fifo file)
              sg = (SETGID) File that is setgid (g+s)
              so = (SOCK) Socket file
              st = (STICKY) Directory with the sticky bit set (+t) and not other-writable
              su = (SETUID) File that is setuid (u+s)
              tw = (STICKY_OTHER_WRITABLE) Directory that is sticky and other-writable (+t,o+w)
              *.extension = Every file using this extension e.g. *.rpm = files with the ending .rpm


              A more complete list is available at Bigsoft - Configuring LS_COLORS.



              On some distributions, you might also want to change the background color for ow "(OTHER_WRITABLE) whose default is non-readable" for example to non-bold blue text on green background.



              You could use for instance LS_COLORS="$LS_COLORS:di=1;33" at the end of your .bashrc file, to get a nice readable bold orange text on black background.



              After you alter your .bashrc file, to put the changes in effect you will have to restart your shell or run source ~/.bashrc.



              Note: You can combine more commands with a colon, for example



              LS_COLORS=$LS_COLORS:'di=1;33:ln=36' ; export LS_COLORS; ls


              Source:



              • COLORS Lscolors - Linux StepByStep

              • Geek Gumbo - Changing the Directory Color in Bash





              share|improve this answer


















              • 2




                This works well, thanks. I personally found it better to set LS_COLORS=$LS_COLORS:'di=1;44:' ; export LS_COLORS which shows the directories in bold white over blue background.
                – isapir
                Mar 18 '16 at 18:52






              • 1




                This doesn't seem to work for me. It looks like there is another config file somewhere that overwrites .bashrc - some colors work, others look differently. Folders are green for instance instead of blue, but files look correctly. What could it be?
                – Nearoo
                Jul 9 '16 at 8:42










              • check if you are using bash or sh, and also check your .profile file in your home directory. and global /etc/bash.bashrc
                – rubo77
                Jul 9 '16 at 9:52






              • 4




                You probably want to modify other writable and sticky other writable dirs. Try something more like LS_COLORS=$LS_COLORS:'tw=01;35:ow=01;35:' ; export LS_COLORS
                – Charles L.
                May 25 '17 at 19:57






              • 1




                that worked for ls, but how do i change the color of the dir I am in, before the # in the cmd prompt?
                – Gaia
                Jan 3 at 6:00












              up vote
              193
              down vote



              accepted







              up vote
              193
              down vote



              accepted






              To change your directory colors, open up your ~/.bashrc file with your editor



              nano ~/.bashrc


              and make the following entry at the end of the file:



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


              Some nice color choices (in this case 0;35 it is purple) are:



              Blue = 34
              Green = 32
              Light Green = 1;32
              Cyan = 36
              Red = 31
              Purple = 35
              Brown = 33
              Yellow = 1;33
              Bold White = 1;37
              Light Grey = 0;37
              Black = 30
              Dark Grey= 1;30


              The first number is the style (1=bold), followed by a semicolon, and then the actual number of the color, possible styles (effects) are:



              0 = default colour
              1 = bold
              4 = underlined
              5 = flashing text (disabled on some terminals)
              7 = reverse field (exchange foreground and background color)
              8 = concealed (invisible)


              The possible backgrounds:



              40 = black background
              41 = red background
              42 = green background
              43 = orange background
              44 = blue background
              45 = purple background
              46 = cyan background
              47 = grey background
              100 = dark grey background
              101 = light red background
              102 = light green background
              103 = yellow background
              104 = light blue background
              105 = light purple background
              106 = turquoise background
              107 = white background


              All possible colors:



              31 = red
              32 = green
              33 = orange
              34 = blue
              35 = purple
              36 = cyan
              37 = grey
              90 = dark grey
              91 = light red
              92 = light green
              93 = yellow
              94 = light blue
              95 = light purple
              96 = turquoise
              97 = white


              These can even be combined, so that a parameter like:



              di=1;4;31;42


              in your LS_COLORS variable would make directories appear in bold underlined red text with a green background!



              To test all these colors and styles in your terminal, you can use one of:



              for i in 002..8 03,4,9,100..7
              do echo -e "$i e[0;$imSubdermatoglyphic texte[00m e[1;$imSubdermatoglyphic texte[00m"
              done

              for i in 002..8 03,4,9,100..7
              do for j in 0 1
              do echo -e "$j;$i e[$j;$imSubdermatoglyphic texte[00m"
              done
              done


              You can also change other kinds of files when using the ls command by defining each kind with:



              bd = (BLOCK, BLK) Block device (buffered) special file
              cd = (CHAR, CHR) Character device (unbuffered) special file
              di = (DIR) Directory
              do = (DOOR) [Door][1]
              ex = (EXEC) Executable file (ie. has 'x' set in permissions)
              fi = (FILE) Normal file
              ln = (SYMLINK, LINK, LNK) Symbolic link. If you set this to ‘target’ instead of a numerical value, the color is as for the file pointed to.
              mi = (MISSING) Non-existent file pointed to by a symbolic link (visible when you type ls -l)
              no = (NORMAL, NORM) Normal (non-filename) text. Global default, although everything should be something
              or = (ORPHAN) Symbolic link pointing to an orphaned non-existent file
              ow = (OTHER_WRITABLE) Directory that is other-writable (o+w) and not sticky
              pi = (FIFO, PIPE) Named pipe (fifo file)
              sg = (SETGID) File that is setgid (g+s)
              so = (SOCK) Socket file
              st = (STICKY) Directory with the sticky bit set (+t) and not other-writable
              su = (SETUID) File that is setuid (u+s)
              tw = (STICKY_OTHER_WRITABLE) Directory that is sticky and other-writable (+t,o+w)
              *.extension = Every file using this extension e.g. *.rpm = files with the ending .rpm


              A more complete list is available at Bigsoft - Configuring LS_COLORS.



              On some distributions, you might also want to change the background color for ow "(OTHER_WRITABLE) whose default is non-readable" for example to non-bold blue text on green background.



              You could use for instance LS_COLORS="$LS_COLORS:di=1;33" at the end of your .bashrc file, to get a nice readable bold orange text on black background.



              After you alter your .bashrc file, to put the changes in effect you will have to restart your shell or run source ~/.bashrc.



              Note: You can combine more commands with a colon, for example



              LS_COLORS=$LS_COLORS:'di=1;33:ln=36' ; export LS_COLORS; ls


              Source:



              • COLORS Lscolors - Linux StepByStep

              • Geek Gumbo - Changing the Directory Color in Bash





              share|improve this answer














              To change your directory colors, open up your ~/.bashrc file with your editor



              nano ~/.bashrc


              and make the following entry at the end of the file:



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


              Some nice color choices (in this case 0;35 it is purple) are:



              Blue = 34
              Green = 32
              Light Green = 1;32
              Cyan = 36
              Red = 31
              Purple = 35
              Brown = 33
              Yellow = 1;33
              Bold White = 1;37
              Light Grey = 0;37
              Black = 30
              Dark Grey= 1;30


              The first number is the style (1=bold), followed by a semicolon, and then the actual number of the color, possible styles (effects) are:



              0 = default colour
              1 = bold
              4 = underlined
              5 = flashing text (disabled on some terminals)
              7 = reverse field (exchange foreground and background color)
              8 = concealed (invisible)


              The possible backgrounds:



              40 = black background
              41 = red background
              42 = green background
              43 = orange background
              44 = blue background
              45 = purple background
              46 = cyan background
              47 = grey background
              100 = dark grey background
              101 = light red background
              102 = light green background
              103 = yellow background
              104 = light blue background
              105 = light purple background
              106 = turquoise background
              107 = white background


              All possible colors:



              31 = red
              32 = green
              33 = orange
              34 = blue
              35 = purple
              36 = cyan
              37 = grey
              90 = dark grey
              91 = light red
              92 = light green
              93 = yellow
              94 = light blue
              95 = light purple
              96 = turquoise
              97 = white


              These can even be combined, so that a parameter like:



              di=1;4;31;42


              in your LS_COLORS variable would make directories appear in bold underlined red text with a green background!



              To test all these colors and styles in your terminal, you can use one of:



              for i in 002..8 03,4,9,100..7
              do echo -e "$i e[0;$imSubdermatoglyphic texte[00m e[1;$imSubdermatoglyphic texte[00m"
              done

              for i in 002..8 03,4,9,100..7
              do for j in 0 1
              do echo -e "$j;$i e[$j;$imSubdermatoglyphic texte[00m"
              done
              done


              You can also change other kinds of files when using the ls command by defining each kind with:



              bd = (BLOCK, BLK) Block device (buffered) special file
              cd = (CHAR, CHR) Character device (unbuffered) special file
              di = (DIR) Directory
              do = (DOOR) [Door][1]
              ex = (EXEC) Executable file (ie. has 'x' set in permissions)
              fi = (FILE) Normal file
              ln = (SYMLINK, LINK, LNK) Symbolic link. If you set this to ‘target’ instead of a numerical value, the color is as for the file pointed to.
              mi = (MISSING) Non-existent file pointed to by a symbolic link (visible when you type ls -l)
              no = (NORMAL, NORM) Normal (non-filename) text. Global default, although everything should be something
              or = (ORPHAN) Symbolic link pointing to an orphaned non-existent file
              ow = (OTHER_WRITABLE) Directory that is other-writable (o+w) and not sticky
              pi = (FIFO, PIPE) Named pipe (fifo file)
              sg = (SETGID) File that is setgid (g+s)
              so = (SOCK) Socket file
              st = (STICKY) Directory with the sticky bit set (+t) and not other-writable
              su = (SETUID) File that is setuid (u+s)
              tw = (STICKY_OTHER_WRITABLE) Directory that is sticky and other-writable (+t,o+w)
              *.extension = Every file using this extension e.g. *.rpm = files with the ending .rpm


              A more complete list is available at Bigsoft - Configuring LS_COLORS.



              On some distributions, you might also want to change the background color for ow "(OTHER_WRITABLE) whose default is non-readable" for example to non-bold blue text on green background.



              You could use for instance LS_COLORS="$LS_COLORS:di=1;33" at the end of your .bashrc file, to get a nice readable bold orange text on black background.



              After you alter your .bashrc file, to put the changes in effect you will have to restart your shell or run source ~/.bashrc.



              Note: You can combine more commands with a colon, for example



              LS_COLORS=$LS_COLORS:'di=1;33:ln=36' ; export LS_COLORS; ls


              Source:



              • COLORS Lscolors - Linux StepByStep

              • Geek Gumbo - Changing the Directory Color in Bash






              share|improve this answer














              share|improve this answer



              share|improve this answer








              edited Jul 11 at 7:24

























              answered May 15 '14 at 7:35









              rubo77

              13.6k2692188




              13.6k2692188







              • 2




                This works well, thanks. I personally found it better to set LS_COLORS=$LS_COLORS:'di=1;44:' ; export LS_COLORS which shows the directories in bold white over blue background.
                – isapir
                Mar 18 '16 at 18:52






              • 1




                This doesn't seem to work for me. It looks like there is another config file somewhere that overwrites .bashrc - some colors work, others look differently. Folders are green for instance instead of blue, but files look correctly. What could it be?
                – Nearoo
                Jul 9 '16 at 8:42










              • check if you are using bash or sh, and also check your .profile file in your home directory. and global /etc/bash.bashrc
                – rubo77
                Jul 9 '16 at 9:52






              • 4




                You probably want to modify other writable and sticky other writable dirs. Try something more like LS_COLORS=$LS_COLORS:'tw=01;35:ow=01;35:' ; export LS_COLORS
                – Charles L.
                May 25 '17 at 19:57






              • 1




                that worked for ls, but how do i change the color of the dir I am in, before the # in the cmd prompt?
                – Gaia
                Jan 3 at 6:00












              • 2




                This works well, thanks. I personally found it better to set LS_COLORS=$LS_COLORS:'di=1;44:' ; export LS_COLORS which shows the directories in bold white over blue background.
                – isapir
                Mar 18 '16 at 18:52






              • 1




                This doesn't seem to work for me. It looks like there is another config file somewhere that overwrites .bashrc - some colors work, others look differently. Folders are green for instance instead of blue, but files look correctly. What could it be?
                – Nearoo
                Jul 9 '16 at 8:42










              • check if you are using bash or sh, and also check your .profile file in your home directory. and global /etc/bash.bashrc
                – rubo77
                Jul 9 '16 at 9:52






              • 4




                You probably want to modify other writable and sticky other writable dirs. Try something more like LS_COLORS=$LS_COLORS:'tw=01;35:ow=01;35:' ; export LS_COLORS
                – Charles L.
                May 25 '17 at 19:57






              • 1




                that worked for ls, but how do i change the color of the dir I am in, before the # in the cmd prompt?
                – Gaia
                Jan 3 at 6:00







              2




              2




              This works well, thanks. I personally found it better to set LS_COLORS=$LS_COLORS:'di=1;44:' ; export LS_COLORS which shows the directories in bold white over blue background.
              – isapir
              Mar 18 '16 at 18:52




              This works well, thanks. I personally found it better to set LS_COLORS=$LS_COLORS:'di=1;44:' ; export LS_COLORS which shows the directories in bold white over blue background.
              – isapir
              Mar 18 '16 at 18:52




              1




              1




              This doesn't seem to work for me. It looks like there is another config file somewhere that overwrites .bashrc - some colors work, others look differently. Folders are green for instance instead of blue, but files look correctly. What could it be?
              – Nearoo
              Jul 9 '16 at 8:42




              This doesn't seem to work for me. It looks like there is another config file somewhere that overwrites .bashrc - some colors work, others look differently. Folders are green for instance instead of blue, but files look correctly. What could it be?
              – Nearoo
              Jul 9 '16 at 8:42












              check if you are using bash or sh, and also check your .profile file in your home directory. and global /etc/bash.bashrc
              – rubo77
              Jul 9 '16 at 9:52




              check if you are using bash or sh, and also check your .profile file in your home directory. and global /etc/bash.bashrc
              – rubo77
              Jul 9 '16 at 9:52




              4




              4




              You probably want to modify other writable and sticky other writable dirs. Try something more like LS_COLORS=$LS_COLORS:'tw=01;35:ow=01;35:' ; export LS_COLORS
              – Charles L.
              May 25 '17 at 19:57




              You probably want to modify other writable and sticky other writable dirs. Try something more like LS_COLORS=$LS_COLORS:'tw=01;35:ow=01;35:' ; export LS_COLORS
              – Charles L.
              May 25 '17 at 19:57




              1




              1




              that worked for ls, but how do i change the color of the dir I am in, before the # in the cmd prompt?
              – Gaia
              Jan 3 at 6:00




              that worked for ls, but how do i change the color of the dir I am in, before the # in the cmd prompt?
              – Gaia
              Jan 3 at 6:00












              up vote
              26
              down vote













              Very simple.
              Add these three lines to ~/.bashrc



              $ vi ~/.bashrc
              export LS_OPTIONS='--color=auto'
              eval "$(dircolors -b)"
              alias ls='ls $LS_OPTIONS'


              If you want to apply the changes in a running bash session, run:



              source ~/.bashrc





              share|improve this answer


















              • 3




                This is the only thing that worked for me.
                – solalito
                Jan 29 '17 at 7:54














              up vote
              26
              down vote













              Very simple.
              Add these three lines to ~/.bashrc



              $ vi ~/.bashrc
              export LS_OPTIONS='--color=auto'
              eval "$(dircolors -b)"
              alias ls='ls $LS_OPTIONS'


              If you want to apply the changes in a running bash session, run:



              source ~/.bashrc





              share|improve this answer


















              • 3




                This is the only thing that worked for me.
                – solalito
                Jan 29 '17 at 7:54












              up vote
              26
              down vote










              up vote
              26
              down vote









              Very simple.
              Add these three lines to ~/.bashrc



              $ vi ~/.bashrc
              export LS_OPTIONS='--color=auto'
              eval "$(dircolors -b)"
              alias ls='ls $LS_OPTIONS'


              If you want to apply the changes in a running bash session, run:



              source ~/.bashrc





              share|improve this answer














              Very simple.
              Add these three lines to ~/.bashrc



              $ vi ~/.bashrc
              export LS_OPTIONS='--color=auto'
              eval "$(dircolors -b)"
              alias ls='ls $LS_OPTIONS'


              If you want to apply the changes in a running bash session, run:



              source ~/.bashrc






              share|improve this answer














              share|improve this answer



              share|improve this answer








              edited Nov 2 '17 at 6:09









              muru

              130k19274467




              130k19274467










              answered Aug 11 '15 at 13:49









              Abdel Hegazi

              36133




              36133







              • 3




                This is the only thing that worked for me.
                – solalito
                Jan 29 '17 at 7:54












              • 3




                This is the only thing that worked for me.
                – solalito
                Jan 29 '17 at 7:54







              3




              3




              This is the only thing that worked for me.
              – solalito
              Jan 29 '17 at 7:54




              This is the only thing that worked for me.
              – solalito
              Jan 29 '17 at 7:54










              up vote
              3
              down vote













              LS_COLORS



              This is a collection of extension:color mappings, suitable to use as your LS COLORS environment variable.






              share|improve this answer




















              • interesting but I can't make this work in ksh.
                – Herman Toothrot
                Aug 17 '16 at 12:50














              up vote
              3
              down vote













              LS_COLORS



              This is a collection of extension:color mappings, suitable to use as your LS COLORS environment variable.






              share|improve this answer




















              • interesting but I can't make this work in ksh.
                – Herman Toothrot
                Aug 17 '16 at 12:50












              up vote
              3
              down vote










              up vote
              3
              down vote









              LS_COLORS



              This is a collection of extension:color mappings, suitable to use as your LS COLORS environment variable.






              share|improve this answer












              LS_COLORS



              This is a collection of extension:color mappings, suitable to use as your LS COLORS environment variable.







              share|improve this answer












              share|improve this answer



              share|improve this answer










              answered May 19 '14 at 22:35









              rubo77

              13.6k2692188




              13.6k2692188











              • interesting but I can't make this work in ksh.
                – Herman Toothrot
                Aug 17 '16 at 12:50
















              • interesting but I can't make this work in ksh.
                – Herman Toothrot
                Aug 17 '16 at 12:50















              interesting but I can't make this work in ksh.
              – Herman Toothrot
              Aug 17 '16 at 12:50




              interesting but I can't make this work in ksh.
              – Herman Toothrot
              Aug 17 '16 at 12:50










              up vote
              2
              down vote













              Further to Hegazi's answer, you can actually control the directory colour, and a lot of other colours using the dircolors command. You can create a configuration file which is well documented.



              You can create a .dircolor file in your home directory as follows:



              dircolors -p > ~/.dircolors


              Then in your ~/.bashrc file add the lines



              eval "`dircolors -b ~/.dircolors`"
              alias ls='ls --color=auto'


              This will create a $LS_COLORS variable for bash. The -c flag will set if for csh. It also flags the ls command to display in colour.



              Edit the value of the DIR attribute as above in the ~/.dircolor file colour to change the colour of the directory (or any of the other included file types for other colours).
              You can also change the colours of specific files, or define your own.






              share|improve this answer
























                up vote
                2
                down vote













                Further to Hegazi's answer, you can actually control the directory colour, and a lot of other colours using the dircolors command. You can create a configuration file which is well documented.



                You can create a .dircolor file in your home directory as follows:



                dircolors -p > ~/.dircolors


                Then in your ~/.bashrc file add the lines



                eval "`dircolors -b ~/.dircolors`"
                alias ls='ls --color=auto'


                This will create a $LS_COLORS variable for bash. The -c flag will set if for csh. It also flags the ls command to display in colour.



                Edit the value of the DIR attribute as above in the ~/.dircolor file colour to change the colour of the directory (or any of the other included file types for other colours).
                You can also change the colours of specific files, or define your own.






                share|improve this answer






















                  up vote
                  2
                  down vote










                  up vote
                  2
                  down vote









                  Further to Hegazi's answer, you can actually control the directory colour, and a lot of other colours using the dircolors command. You can create a configuration file which is well documented.



                  You can create a .dircolor file in your home directory as follows:



                  dircolors -p > ~/.dircolors


                  Then in your ~/.bashrc file add the lines



                  eval "`dircolors -b ~/.dircolors`"
                  alias ls='ls --color=auto'


                  This will create a $LS_COLORS variable for bash. The -c flag will set if for csh. It also flags the ls command to display in colour.



                  Edit the value of the DIR attribute as above in the ~/.dircolor file colour to change the colour of the directory (or any of the other included file types for other colours).
                  You can also change the colours of specific files, or define your own.






                  share|improve this answer












                  Further to Hegazi's answer, you can actually control the directory colour, and a lot of other colours using the dircolors command. You can create a configuration file which is well documented.



                  You can create a .dircolor file in your home directory as follows:



                  dircolors -p > ~/.dircolors


                  Then in your ~/.bashrc file add the lines



                  eval "`dircolors -b ~/.dircolors`"
                  alias ls='ls --color=auto'


                  This will create a $LS_COLORS variable for bash. The -c flag will set if for csh. It also flags the ls command to display in colour.



                  Edit the value of the DIR attribute as above in the ~/.dircolor file colour to change the colour of the directory (or any of the other included file types for other colours).
                  You can also change the colours of specific files, or define your own.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Mar 7 '17 at 20:25









                  smilingfrog

                  211




                  211




















                      up vote
                      0
                      down vote













                      The is my approach for ls command with commonly used options:



                      add the following lines into a file called ~/.alias



                      alias ll='ls -lhF --color=auto'
                      alias llt='ls -lht --color=auto'
                      alias lla='ls -alF --color=auto'
                      alias la='ls -A --color=auto'
                      alias l='ls -CF --color=auto'
                      alias ls="ls --color=auto"


                      add the following lines into ~/.bashrc



                      if [ -f ~/.alias ]; then
                      . ~/.alias
                      fi





                      share|improve this answer
















                      • 1




                        you only need to add --color=auto to the ls alias - the other aliases with inherit the setting
                        – Stuart Cardall
                        Oct 25 '17 at 16:22














                      up vote
                      0
                      down vote













                      The is my approach for ls command with commonly used options:



                      add the following lines into a file called ~/.alias



                      alias ll='ls -lhF --color=auto'
                      alias llt='ls -lht --color=auto'
                      alias lla='ls -alF --color=auto'
                      alias la='ls -A --color=auto'
                      alias l='ls -CF --color=auto'
                      alias ls="ls --color=auto"


                      add the following lines into ~/.bashrc



                      if [ -f ~/.alias ]; then
                      . ~/.alias
                      fi





                      share|improve this answer
















                      • 1




                        you only need to add --color=auto to the ls alias - the other aliases with inherit the setting
                        – Stuart Cardall
                        Oct 25 '17 at 16:22












                      up vote
                      0
                      down vote










                      up vote
                      0
                      down vote









                      The is my approach for ls command with commonly used options:



                      add the following lines into a file called ~/.alias



                      alias ll='ls -lhF --color=auto'
                      alias llt='ls -lht --color=auto'
                      alias lla='ls -alF --color=auto'
                      alias la='ls -A --color=auto'
                      alias l='ls -CF --color=auto'
                      alias ls="ls --color=auto"


                      add the following lines into ~/.bashrc



                      if [ -f ~/.alias ]; then
                      . ~/.alias
                      fi





                      share|improve this answer












                      The is my approach for ls command with commonly used options:



                      add the following lines into a file called ~/.alias



                      alias ll='ls -lhF --color=auto'
                      alias llt='ls -lht --color=auto'
                      alias lla='ls -alF --color=auto'
                      alias la='ls -A --color=auto'
                      alias l='ls -CF --color=auto'
                      alias ls="ls --color=auto"


                      add the following lines into ~/.bashrc



                      if [ -f ~/.alias ]; then
                      . ~/.alias
                      fi






                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered Aug 12 '17 at 5:33









                      Jonathan L

                      1012




                      1012







                      • 1




                        you only need to add --color=auto to the ls alias - the other aliases with inherit the setting
                        – Stuart Cardall
                        Oct 25 '17 at 16:22












                      • 1




                        you only need to add --color=auto to the ls alias - the other aliases with inherit the setting
                        – Stuart Cardall
                        Oct 25 '17 at 16:22







                      1




                      1




                      you only need to add --color=auto to the ls alias - the other aliases with inherit the setting
                      – Stuart Cardall
                      Oct 25 '17 at 16:22




                      you only need to add --color=auto to the ls alias - the other aliases with inherit the setting
                      – Stuart Cardall
                      Oct 25 '17 at 16:22










                      up vote
                      0
                      down vote













                      The --color=auto option doesn't work for me using iTerm2 on my Mac. The -G option works though. I put the following alias in my ~/.profile and now directories are colored and have a trailing / appended:



                      alias ls='ls -F -G'





                      share|improve this answer
























                        up vote
                        0
                        down vote













                        The --color=auto option doesn't work for me using iTerm2 on my Mac. The -G option works though. I put the following alias in my ~/.profile and now directories are colored and have a trailing / appended:



                        alias ls='ls -F -G'





                        share|improve this answer






















                          up vote
                          0
                          down vote










                          up vote
                          0
                          down vote









                          The --color=auto option doesn't work for me using iTerm2 on my Mac. The -G option works though. I put the following alias in my ~/.profile and now directories are colored and have a trailing / appended:



                          alias ls='ls -F -G'





                          share|improve this answer












                          The --color=auto option doesn't work for me using iTerm2 on my Mac. The -G option works though. I put the following alias in my ~/.profile and now directories are colored and have a trailing / appended:



                          alias ls='ls -F -G'






                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Nov 6 '17 at 16:00









                          John Slavick

                          1012




                          1012



























                               

                              draft saved


                              draft discarded















































                               


                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function ()
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f466198%2fhow-do-i-change-the-color-for-directories-with-ls-in-the-console%23new-answer', 'question_page');

                              );

                              Post as a guest













































































                              Popular posts from this blog

                              pylint3 and pip3 broken

                              Missing snmpget and snmpwalk

                              How to enroll fingerprints to Ubuntu 17.10 with VFS491