未加星标

Linux文件类型及颜色标识整理

字体大小 | |
[系统(linux) 所属分类 系统(linux) | 发布者 店小二04 | 时间 2016 | 作者 红领巾 ] 0人收藏点击收藏

linux 文件类型及颜色标识整理

M21陆东贵

使用工具:

ls 命令

ls l: 以常格式显示文件及目录的详细信息

例如:-rw-r r 1 root root 0 10月 12 13:32 2016-10-12-13-32-11

-rw――-. 1 root root 1487 9 月 12 10:56 anaconda-ks.cfg

drwxr-xr-x 3 root root 51 10 月 14 10:18 application

根据示例显示,各种文件的文件名是以不同颜色显示来区分

文件类型介绍:

:常规文件,普通文件;

d :目录文件,路径映射;

b :块设备文件;支持以“block”为单位进行随机访问;

c :字符设备文件,支持以“character”为单位进行线性访问;

mojor number :主设备号,表示设备类型,进而确定要加载的驱动;

minor number :次设备号,标识同一类型中的不同设备;

l :符号链接文件;

p :命令管道文件;

s :socket 套接字文件;

文件颜色介绍:

蓝色: 目录 ;

绿色: 可执行文件 ;

红色: 压缩文件 ;

浅蓝色: 链接文件 ;

白色: 其他文件 ;

黄色: 设备文件,包括block, char, fifo。

红色闪烁:链接的文件有问题了;

拓展:

1 、 可以使用dircolors -p看到缺省的颜色设置,包括各种颜色和“粗体”,下划线,闪烁等定义。

2 、 在/etc/DIR_COLORS文件,这是一个着色控制的模版。

3 、 修改其他颜色的方法:

首先

# vi /etc/DIR_COLORS

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

我把它改成了“DIR 01;37;44”,37是字体白色,44是字背景蓝色,视觉效果还可以,而且习惯上也能接受。

然后,执行

# eval `dircolors /etc/DIR_COLORS`

4 、 以上方法是对全局修改,个人用户修改方法:

将/etc/DIR_COLORS文件cp到~/下,并改名为.dir_colors,再修改这个文件就可以了

以下是官方文档说明:

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

本文系统(linux)相关术语:linux系统 鸟哥的linux私房菜 linux命令大全 linux操作系统

主题: LinuxSlackTIOPT
分页:12
转载请注明
本文标题:Linux文件类型及颜色标识整理
本站链接:http://www.codesec.net/view/484474.html
分享请点击:


1.凡CodeSecTeam转载的文章,均出自其它媒体或其他官网介绍,目的在于传递更多的信息,并不代表本站赞同其观点和其真实性负责;
2.转载的文章仅代表原创作者观点,与本站无关。其原创性以及文中陈述文字和内容未经本站证实,本站对该文以及其中全部或者部分内容、文字的真实性、完整性、及时性,不作出任何保证或承若;
3.如本站转载稿涉及版权等问题,请作者及时联系本站,我们会及时处理。
登录后可拥有收藏文章、关注作者等权限...
技术大类 技术大类 | 系统(linux) | 评论(0) | 阅读(24)