标点符(钱魏 Way)

Linux学习笔记:文件的颜色

在使用ls 命令时,可以发现不同类型的文件,颜色不同,具体每种颜色代表哪类文件?今天就一起来学习下。

默认情况下,在命令行中输入 dircolors 即可了解到具体的配置信息:

配置信息中(rs、di、ln等)对应的是不同的不同类型的文件,常见的内容为:

  • di Directory
  • fi File
  • ln Symbolic Link
  • pi Fifo file
  • so Socket file
  • bd Block (buffered) special file
  • cd Character (unbuffered) special file
  • or Symbolic Link pointing to a non-existent file (orphan)
  • mi Non-existent file pointed to by a symbolic link (visible when you type ls -l)
  • ex File which is executable (ie. has ‘x’ set in permissions).

后面的数字,代表的是呈现样式:

  • 0 = Default Colour
  • 1 = Bold
  • 4 = Underlined
  • 5 = Flashing Text
  • 7 = Reverse Field
  • 31 = Red
  • 32 = Green
  • 33 = Orange
  • 34 = Blue
  • 35 = Purple
  • 36 = Cyan
  • 37 = Grey
  • 40 = Black Background
  • 41 = Red Background
  • 42 = Green Background
  • 43 = Orange Background
  • 44 = Blue Background
  • 45 = Purple Background
  • 46 = Cyan Background
  • 47 = Grey Background
  • 90 = Dark Grey
  • 91 = Light Red
  • 92 = Light Green
  • 93 = Yellow
  • 94 = Light Blue
  • 95 = Light Purple
  • 96 = Turquoise
  • 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

其中一个类型文件可以设置多种不同的呈现样式,如: di=5;31;42 ,不同呈现样式之间用分号;隔开,不同文件类型之间用冒号:隔开。

另外更加完整的信息可以在/etc/DIR_COLORS 文件中看到:

参考地址:

码字很辛苦,转载请注明来自标点符《Linux学习笔记:文件的颜色》

评论