How do I change the color for directories with ls in the console?
![Creative The name of the picture](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgO9GURib1T8z7lCwjOGLQaGtrueEthgQ8LO42ZX8cOfTqDK4jvDDpKkLFwf2J49kYCMNW7d4ABih_XCb_2UXdq5fPJDkoyg7-8g_YfRUot-XnaXkNYycsNp7lA5_TW9td0FFpLQ2APzKcZ/s1600/1.jpg)
![Creative The name of the picture](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYQ0N5W1qAOxLP7t7iOM6O6AzbZnkXUy16s7P_CWfOb5UbTQY_aDsc727chyphenhyphen5W4IppVNernMMQeaUFTB_rFzAd95_CDt-tnwN-nBx6JyUp2duGjPaL5-VgNO41AVsA_vu30EJcipdDG409/s400/Clash+Royale+CLAN+TAG%2523URR8PPP.png)
up vote
126
down vote
favorite
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
add a comment |Â
up vote
126
down vote
favorite
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
add a comment |Â
up vote
126
down vote
favorite
up vote
126
down vote
favorite
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
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
colors console ls
edited Feb 27 '15 at 1:33
asked May 15 '14 at 7:27
rubo77
13.6k2692188
13.6k2692188
add a comment |Â
add a comment |Â
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
2
This works well, thanks. I personally found it better to setLS_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 likeLS_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
 |Â
show 6 more comments
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
3
This is the only thing that worked for me.
â solalito
Jan 29 '17 at 7:54
add a comment |Â
up vote
3
down vote
LS_COLORS
This is a collection of extension:color mappings, suitable to use as your LS COLORS environment variable.
interesting but I can't make this work in ksh.
â Herman Toothrot
Aug 17 '16 at 12:50
add a comment |Â
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.
add a comment |Â
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
1
you only need to add--color=auto
to thels
alias - the other aliases with inherit the setting
â Stuart Cardall
Oct 25 '17 at 16:22
add a comment |Â
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'
add a comment |Â
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
2
This works well, thanks. I personally found it better to setLS_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 likeLS_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
 |Â
show 6 more comments
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
2
This works well, thanks. I personally found it better to setLS_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 likeLS_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
 |Â
show 6 more comments
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
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
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 setLS_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 likeLS_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
 |Â
show 6 more comments
2
This works well, thanks. I personally found it better to setLS_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 likeLS_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
 |Â
show 6 more comments
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
3
This is the only thing that worked for me.
â solalito
Jan 29 '17 at 7:54
add a comment |Â
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
3
This is the only thing that worked for me.
â solalito
Jan 29 '17 at 7:54
add a comment |Â
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
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
edited Nov 2 '17 at 6:09
muru
130k19274467
130k19274467
answered Aug 11 '15 at 13:49
![](https://i.stack.imgur.com/tSPKt.jpg?s=32&g=1)
![](https://i.stack.imgur.com/tSPKt.jpg?s=32&g=1)
Abdel Hegazi
36133
36133
3
This is the only thing that worked for me.
â solalito
Jan 29 '17 at 7:54
add a comment |Â
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
add a comment |Â
up vote
3
down vote
LS_COLORS
This is a collection of extension:color mappings, suitable to use as your LS COLORS environment variable.
interesting but I can't make this work in ksh.
â Herman Toothrot
Aug 17 '16 at 12:50
add a comment |Â
up vote
3
down vote
LS_COLORS
This is a collection of extension:color mappings, suitable to use as your LS COLORS environment variable.
interesting but I can't make this work in ksh.
â Herman Toothrot
Aug 17 '16 at 12:50
add a comment |Â
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.
LS_COLORS
This is a collection of extension:color mappings, suitable to use as your LS COLORS environment variable.
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
add a comment |Â
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
add a comment |Â
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.
add a comment |Â
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.
add a comment |Â
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.
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.
answered Mar 7 '17 at 20:25
smilingfrog
211
211
add a comment |Â
add a comment |Â
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
1
you only need to add--color=auto
to thels
alias - the other aliases with inherit the setting
â Stuart Cardall
Oct 25 '17 at 16:22
add a comment |Â
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
1
you only need to add--color=auto
to thels
alias - the other aliases with inherit the setting
â Stuart Cardall
Oct 25 '17 at 16:22
add a comment |Â
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
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
answered Aug 12 '17 at 5:33
![](https://i.stack.imgur.com/m0k2I.png?s=32&g=1)
![](https://i.stack.imgur.com/m0k2I.png?s=32&g=1)
Jonathan L
1012
1012
1
you only need to add--color=auto
to thels
alias - the other aliases with inherit the setting
â Stuart Cardall
Oct 25 '17 at 16:22
add a comment |Â
1
you only need to add--color=auto
to thels
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
add a comment |Â
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'
add a comment |Â
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'
add a comment |Â
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'
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'
answered Nov 6 '17 at 16:00
John Slavick
1012
1012
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password