# Below are the color init strings for the basic file types. A color init
# string consists of one or more of the following numeric codes:
# Attribute codes:
# 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed
# Text color codes:
# 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white
# Background color codes:
# 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white
di 表示目录
ln 表示连接
or 表示坏掉的连接
ow 表示权限是 777 的目录
ex 表示可执行文件
##########################################################
/etc/DIR_COLORS 文件类型
NORMAL 00 # global default, although everything should be something.
FILE 00 # normal file
DIR 01;34 # directory
LINK 01;36 # symbolic link
FIFO 40;33 # pipe
SOCK 01;35 # socket
BLK 40;33;01 # block device driver
CHR 40;33;01 # character device driver
ORPHAN 01;05;37;41 # orphaned syminks
MISSING 01;05;37;41 # ... and the files they point to
.cmd 01;32 # executables (bright green)
.exe 01;32
.com 01;32
.btm 01;32
.bat 01;32
.sh 01;32
.csh 01;32
.tar 01;31 # archives or compressed (bright red)
.tgz 01;31
.arj 01;31
.taz 01;31
.lzh 01;31
.zip 01;31
.z 01;31
.Z 01;31
.gz 01;31
.bz2 01;31
.bz 01;31
.tz 01;31
.rpm 01;31
.cpio 01;31
.jpg 01;35 # image formats
.gif 01;35
.bmp 01;35
.xbm 01;35
.xpm 01;35
.png 01;35
.tif 01;35
##########################################################
Linux / Unix Command: dir_colors
NAMEdir_colors - configuration file for
dircolors
(1)
DESCRIPTIONThe program
ls
(1) uses the environment variable
LS_COLORS
to determine the colors in which the filenames are to be displayed. This environment variable is usually set by a command like
eval `dircolors some_path/dir_colors`
found in a system default shell initialization file, like
/etc/profile
or
/etc/csh.cshrc
. (See also
dircolors
(1).) Usually, the file used here is
/etc/DIR_COLORS
and can be overridden by a
.dir_colors
file in one's home directory.
This configuration file consists of several statements, one per line. Anything right of a hash mark (#) is treated as a comment, if the hash mark is at the beginning of a line or is preceded by at least one whitespace. Blank lines are ignored.
The
global
section of the file consists of any statement before the first
TERM
statement. Any statement in the global section of the file is considered valid for all terminal types. Following the global section is one or more
terminal-specific
sections, preceded by one or more
TERM
statements which specify the terminal types (as given by the
TERM
environment variable) the following declarations apply to. It is always possible to override a global declaration by a subsequent terminal-specific one.
The following statements are recognized; case is insignificant:
TERM
terminal-type
Starts a terminal-specific section and specifies which terminal it applies to. Multiple
TERM
statements can be used to create a section which applies for several terminal types.
COLOR yes|all|no|none|tty
(Slackware only; ignored by GNU
dircolors
(1).) Specifies that colorization should always be enabled (
yes
or
all
), never enabled (
no
or
none
), or enabled only if the output is a terminal (
tty
). The default is
no
.
EIGHTBIT yes|no
(Slackware only; ignored by GNU
dircolors
(1).) Specifies that eight-bit ISO 8859 characters should be enabled by default. For compatibility reasons, this can also be specified as 1 for
yes
or 0 for
no
. The default is
no
.
OPTIONS
options
(Slackware only; ignored by GNU
dircolors
(1).) Adds command line options to the default
ls
command line. The options can be any valid
ls
command line options, and should include the leading minus sign. Please note that
dircolors
does not verify the validity of these options.
NORMAL
color-sequence
Specifies the color used for normal (non-filename) text.
FILE
color-sequence
Specifies the color used for a regular file.
DIR
color-sequence
Specifies the color used for directories.
LINK
color-sequence
Specifies the color used for a symbolic link.
ORPHAN
color-sequence
Specifies the color used for an orphaned symbolic link (one which points to a nonexistent file). If this is unspecified,
ls
will use the
LINK
color instead.
MISSING
color-sequence
Specifies the color used for a missing file (a nonexistent file which nevertheless has a symbolic link pointing to it). If this is unspecified,
ls
will use the
FILE
color instead.
FIFO
color-sequence
Specifies the color used for a FIFO (named pipe).
SOCK
color-sequence
Specifies the color used for a socket.
DOOR
color-sequence
(Supported since file-utils 4.1) Specifies the color used for a door (Solaris 2.5 and later).
BLK
color-sequence
Specifies the color used for a block device special file.
CHR
color-sequence
Specifies the color used for a character device special file.
EXEC
color-sequence
Specifies the color used for a file with the executable attribute set.
LEFTCODE
color-sequence
Specifies the
left code
for non-ISO 6429 terminals (see below).
RIGHTCODE
color-sequence
Specifies the
right code
for non-ISO 6429 terminals (see below).
ENDCODE
color-sequence
Specifies the
end code
for non-ISO 6429 terminals (see below).
*
extension
color-sequence
Specifies the color used for any file that ends in
extension
.
.
extension
color-sequence
Same as
*
.
extension
. Specifies the color used for any file that ends in .
extension
. Note that the period is included in the extension, which makes it impossible to specify an extension not starting with a period, such as
~
for
emacs
backup files. This form should be considered obsolete.
ISO 6429 (ANSI) COLOR SEQUENCESMost color-capable ASCII terminals today use ISO 6429 (ANSI) color sequences, and many common terminals without color capability, including
xterm
and the widely used and cloned DEC VT100, will recognize ISO 6429 color codes and harmlessly eliminate them from the output or emulate them.
ls
uses ISO 6429 codes by default, assuming colorization is enabled.
ISO 6429 color sequences are composed of sequences of numbers separated by semicolons. The most common codes are:
0 to restore default color
1 for brighter colors
4 for underlined text
5 for flashing text
30 for black foreground
31 for red foreground
32 for green foreground
33 for yellow (or brown) foreground
34 for blue foreground
35 for purple foreground
36 for cyan foreground
37 for white (or gray) foreground
40 for black background
41 for red background
42 for green background
43 for yellow (or brown) background
44 for blue background
45 for purple background
46 for cyan background
47 for white (or gray) background
Not all commands will work on all systems or display devices.
ls
uses the following defaults:
NORMAL
0 Normal (non-filename) text
FILE
0 Regular file
DIR
32 Directory
LINK
36 Symbolic link
ORPHAN
undefined Orphanned symbolic link
MISSING
undefined Missing file
FIFO
31 Named pipe (FIFO)
SOCK
33 Socket
BLK
44;37 Block device
CHR
44;37 Character device
EXEC
35 Executable file
A few terminal programs do not recognize the default properly. If all text gets colorized after you do a directory listing, change the
NORMAL
and
FILE
codes to the numerical codes for your normal foreground and background colors.
OTHER TERMINAL TYPES (ADVANCED CONFIGURATION)If you have a color-capable (or otherwise highlighting) terminal (or printer!) which uses a different set of codes, you can still generate a suitable setup. To do so, you will have to use the
LEFTCODE
,
RIGHTCODE
, and
ENDCODE
definitions.
When writing out a filename,
ls
generates the following output sequence:
LEFTCODE
typecode
RIGHTCODE
filename
ENDCODE
, where the
typecode
is the color sequence that depends on the type or name of file. If the
ENDCODE
is undefined, the sequence
LEFTCODE NORMAL RIGHTCODE
will be used instead. The purpose of the left- and rightcodes is merely to reduce the amount of typing necessary (and to hide ugly escape codes away from the user). If they are not appropriate for your terminal, you can eliminate them by specifying the respective keyword on a line by itself.
NOTE:
If the
ENDCODE
is defined in the global section of the setup file, it
cannot
be undefined in a terminal-specific section of the file. This means any
NORMAL
definition will have no effect. A different
ENDCODE
can, however, be specified, which would have the same effect.
ESCAPE SEQUENCESTo specify control- or blank characters in the color sequences or filename extensions, either C-style \-escaped notation or
stty
-style ^-notation can be used. The C-style notation includes the following characters:
\a
Bell (ASCII 7)
\b
Backspace (ASCII 8)
\e
Escape (ASCII 27)
\f
Form feed (ASCII 12)
\n
Newline (ASCII 10)
\r
Carriage Return (ASCII 13)
\t
Tab (ASCII 9)
\v
Vertical Tab (ASCII 11)
\?
Delete (ASCII 127)
\
nnn
Any character (octal notation)
\x
nnn
Any character (hexadecimal notation)
\_
Space
\\
Backslash (\)
\^
Caret (^)
\#
Hash mark (#)
Please note that escapes are necessary to enter a space, backslash, caret, or any control character anywhere in the string, as well as a hash mark as the first character.
==============================================================================
修改ls目录的颜色
linux系统默认目录颜色是蓝色的,在黑背景下看不清楚,可以通过以下2种方法修改ls查看的颜色
方法一:
1、在~/.bash_profile文件中添加LS_COLORS
export LS_COLORS='no=00:fi=00:di=01;33:ln=01;36:pi=40;33:so=01;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:ex=01;35:*.cmd=01;35:*.exe=01;35:*.com=01;35:*.btm=01;35:*.bat=01;35:*.sh=01;35:*.csh=01;35:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.bz=01;31:*.tz=01;31:*.rpm=01;31:*.cpio=01;31:*.jpg=01;35:*.gif=01;35:*.bmp=01;35:*.xbm=01;35:*.xpm=01;35:*.png=01;35:*.tif=01;35:'
2、source ~/.bash_profile即可
方法二:
1、拷贝/etc/DIR_COLORS文件为当前主目录的 .dir_colors
cp /etc/DIR_COLORS ~/.dir_colors
2、修改~/.dir_colors中DIR对应的颜色
vim ~/.dir_colors
第59行:DIR 01;34(01:粗体,34:蓝色)
修改为:DIR 01;33(01:粗体,33:黄色)
解释
1、文件类型
1)直接用,有以下几种:
no NORMAL, NORM 全局默认
fi FILE 普通文件
di DIR 目录
ln SYMLINK, LINK, LNK 链接
pi FIFO, PIPE 管道
do DOOR Door
bd BLOCK, BLK 块设备
cd CHAR, CHR 字符设备
or ORPHAN 目标不存在到符号链接
so SOCK 套接字Socket
su SETUID 属主setuid有效的文件
sg SETGID 属组setuid有效到文件
tw STICKY_OTHER_WRITABLE Directory that is sticky and other-writable ( t,o w)
ow OTHER_WRITABLE Directory that is other-writable (o w) and not sticky
st STICKY Directory with the sticky bit set ( t) and not other-writable
ex EXEC Executable file (i.e. has ‘x’ set in permissions)
mi MISSING Non-existent file pointed to by a symbolic link (visible when you type ls -l)
lc LEFTCODE, LEFT Opening terminal code
rc RIGHTCODE, RIGHT Closing terminal code
ec ENDCODE, END Non-filename text
2)扩展名通过“.”加上扩展名
*.extension Every file using this extension e.g. *.jpg
2、效果的具体代码如下
* 效果列表:
00 默认
01 加粗
04 下划线
05 闪烁
07 反显
08 隐藏
* 颜色列表:
31~37 分别表示前景色为红、绿、橙、蓝、紫、青、灰
90~97 分别表示前景色为深灰、淡红、淡绿、黄色、淡蓝、淡紫、青绿、白色
40~47 分别表示背景色为黑、红、绿、橙、蓝、紫、青、灰
100~106 分别表示背景色为深灰、淡红、淡绿、黄色、淡蓝、淡紫、青绿