Linux中默认显示的文件类型颜色以及如何配置

0    130    1

Tags:

👉 本文共约1358个字,系统预计阅读时间或需6分钟。

默认颜色含义

白色:表示普通文件,如文本文件、配置文件、源码文件等
蓝色:表示目录
绿色:表示可执行文件,可执行的程序
红色:表示压缩文件或者包文件
浅蓝色:链接文件,主要是使用ln命令建立的文件等
红色闪烁:表示链接的文件有问题
黄色:表示设备文件
灰色:表示其他文件

ls显示颜色

在一般的情况下,ls输出内容是有颜色的,比如目录是蓝色,压缩文件是红字的显示。如果没有颜色,可以加上参数。当然也可以去掉颜色。

--color=never 表示输出输出没有彩色
--color=auto 表示自动
--color=always 表示输出内容有彩色

linux中关于文件夹和文件显示不同颜色的设置

1,先把关于文件夹的配色方案的文件cp到根目录下

cp /etc/DIR_COLORS ~/.dir_colors

2,然后编辑这个文件

vi ~/.dir_colors

3, 找到DIR这一行 设置DIR后面的参数 上面有每个数字代表的颜色,选择自己喜欢的颜色

文件内设定的“DIR 01;34”,为ls命令的目录的颜色设置,01表示粗体,34表示字体蓝色。

改成“DIR 01;37;44”,37是字体白色,44是字背景蓝色。//这个是推荐的,你可以根据个人爱好自行选择

4,最后执行

eval dircolors ~/.dir_colors
注意命令中的`符号为键盘~符号下面的那个,再执行ls命令就有效果。

如果使用不习惯,就建议换成 DIR 01;36

然后ls 看看有没有效果

变量

ls指令显示的文件,可以通过设置环境变量LS_COLORS,修改不同类型文件显示的颜色。LS_COLORS可以通过指定文件设定,用dircolors -p可以 看到缺省的颜色设置,包括各种颜色和“粗体”,下划线,闪烁等定义。

本人提供Oracle、MySQL、PG等数据库的培训和考证业务,私聊QQ646634621或微信db_bao,谢谢!

LSCOLORS中,字母代表的颜色如下:

  • a 黑色
  • b 红色
  • c 绿色
  • d 棕色
  • e 蓝色
  • f 洋红色
  • g 青色
  • h 浅灰色
  • A 黑色粗体
  • B 红色粗体
  • C 绿色粗体
  • D 棕色粗体
  • E 蓝色粗体
  • F 洋红色粗体
  • G 青色粗体
  • H 浅灰色粗体
  • x 系统默认颜色

所以,如果我们想把目录显示成红色,就可以把LSCOLORS设置为bxfxaxdxcxegedabagacad就可以了

LSCOLORS 的含义:

LSCOLORS The value of this variable describes what color to use
for which attribute when colors are enabled with
CLICOLOR. This string is a concatenation of pairs of the
format fb, where f is the foreground color and b is the
background color.

The color designators are as follows:

a black
b red
c green
d brown
e blue
f magenta
g cyan
h light grey
A bold black, usually shows up as dark grey
B bold red
C bold green
D bold brown, usually shows up as yellow
E bold blue
F bold magenta
G bold cyan
H bold light grey; looks like bright white
x default foreground or background

Note that the above are standard ANSI colors. The actual
display may differ depending on the color capabilities of
the terminal in use.

The order of the attributes are as follows:

\1. directory
\2. symbolic link
\3. socket
\4. pipe
\5. executable
\6. block special
\7. character special
\8. executable with setuid bit set
\9. executable with setgid bit set
\10. directory writable to others, with sticky bit
\11. directory writable to others, without sticky
bit

The default is “exfxcxdxbxegedabagacad”, i.e. blue fore-
ground and default background for regular directories,
black foreground and red background for setuid executa-
bles, etc.

颜色含义

标签:

头像

小麦苗

学习或考证,均可联系麦老师,请加微信db_bao或QQ646634621

您可能还喜欢...

发表回复

嘿,我是小麦,需要帮助随时找我哦
  • 18509239930
  • 个人微信

  • 麦老师QQ聊天
  • 个人邮箱
  • 点击加入QQ群
  • 个人微店

  • 回到顶部
返回顶部