更新升级 专属应用 系统故障 硬件故障 电脑汽车 鸿蒙刷机 鸿蒙开发Linux教程 鸿蒙开发Linux命令
当前位置:HMXT之家 > 鸿蒙开发Linux命令 > Linux dir、dip、dig、dircolors命令的用法及解释

Linux dir、dip、dig、dircolors命令的用法及解释

更新时间:2022-01-22 15:41:06浏览次数:323+次

以下为你详细解释dir、dip、dig、dircolors命令的用法。

\

Linux dir命令的用法及解释

Linux dir命令相关的命令:ls。

1、用法

dir [选项]... [文件]...

List information about the FILEs (the current directory by default).

Sort entries alphabetically if none of -cftuvSUX nor --sort is specified.

长选项必须使用的参数对于短选项时也是必需使用的。

-a, --all                     不隐藏任何以. 开始的项目

-A, --almost-all              列出除. 及.. 以外的任何项目

--author                  与-l 同时使用时列出每个文件的作者

-b, --escape                  以八进制溢出序列表示不可打印的字符

--block-size=SIZE        scale sizes by SIZE before printing them.  E.g.,

`--block-size=M' prints sizes in units of

1,048,576 bytes.  See SIZE format below.

-B, --ignore-backups         do not list implied entries ending with ~

-c                           with -lt: sort by, and show, ctime (time of last

modification of file status information)

with -l: show ctime and sort by name

otherwise: sort by ctime, newest first

-C                            每栏由上至下列出项目

--color[=WHEN]            控制是否使用色彩分辨文件。WHEN 可以是"never"(默认)、"always"或"auto"其中之一

-d, --directory               当遇到目录时列出目录本身而非目录内的文件

-D, --dired                   产生适合Emacs 的dired 模式使用的结果

-f                            不进行排序,-aU 选项生效,-lst 选项失效

-F, --classify                加上文件类型的指示符号(*/=@| 其中一个)

--format=关键字           交错-x,逗号分隔-m,水平-x,长-l,单栏-1,详细-l,垂直-C

--full-time               即-l --time-style=full-iso

-g                            类似-l,但不列出所有者

--group-directories-first

在文件前分组目录。此选项可与--sort 一起使用,但是一旦使用--sort=none (-U)将禁用分组

-G, --no-group                以一个长列表的形式,不输出组名

-h, --human-readable          与-l 一起,以易于阅读的格式输出文件大小

(例如 1K 234M 2G)

--si                      同上面类似,但是使用1000 为基底而非1024

-H, --dereference-command-line

跟随命令行列出的符号链接

--dereference-command-line-symlink-to-dir

跟随命令行列出的目录的符号链接

--hide=PATTERN            隐藏符合PATTERN 模式的项目

(-a 或 -A 将覆盖此选项)

--indicator-style=方式    指定在每个项目名称后加上指示符号方式:

none (默认),classify (-F),file-type (-p)

-i, --inode                   显示每个文件的inode 号

-I, --ignore=PATTERN          不显示任何符合指定shell PATTERN 的项目

-k                            即--block-size=1K

-l                            使用较长格式列出信息

-L, --dereference             当显示符号链接的文件信息时,显示符号链接所指示的对象而并非符号链接本身的信息

-m                            所有项目以逗号分隔,并填满整行行宽

-n, --numeric-uid-gid         类似 -l,但列出UID 及GID 号

-N, --literal                 输出未经处理的项目名称 (如不特别处理控制字符)

-o                            类似 -l,但不列出有关组的信息

-p,  --indicator-style=slash  对目录加上表示符号"/"

-q, --hide-control-chars      以"?"字符代替无法打印的字符

--show-control-chars      直接显示无法打印的字符 (这是默认方式,除非调用的程序名称是"ls"而且是在终端输出结果)

-Q, --quote-name              将条目名称括上双引号

--quoting-style=方式      使用指定的quoting 方式显示条目的名称:

literal、locale、shell、shell-always、c、escape

-r, --reverse                 逆序排列

-R, --recursive               递归显示子目录

-s, --size                    以块数形式显示每个文件分配的尺寸

-S                            根据文件大小排序

--sort=WORD               以下是可选用的WORD 和它们代表的相应选项:

extension -X       status   -c

none      -U       time     -t

size      -S       atime    -u

time      -t       access   -u

version   -v       use      -u

--time=WORD               和-l 同时使用时显示WORD 所代表的时间而非修改时间:atime、access、use、ctime 或status;加上

--sort=time 选项时会以指定时间作为排序关键字

--time-style=STYLE        和-l 同时使用时根据STYLE 代表的格式显示时间:full-iso、iso、locale、posix-iso、+FORMAT。

FORMAT 即是"date"所用的时间格式;如果FORMAT是FORMAT1<换行>FORMAT2,FORMAT1 适用于较旧的文件而FORMAT2 适用于较新的文件;如果STYLE以"posix-"开头,则STYLE 仅在POSIX 语系之外生效。

-t                            根据修改时间排序

-T, --tabsize=宽度    指定制表符(Tab)的宽度,而非8 个字符

-t                    sort by modification time, newest first

-T, --tabsize=COLS    assume tab stops at each COLS instead of 8

-u                    同-lt 一起使用:按照访问时间排序并显示

同-l一起使用:显示访问时间并按文件名排序

其他:按照访问时间排序

-U                    不进行排序;按照目录顺序列出项目

-v                    在文本中进行数字(版本)的自然排序

-w, --width=COLS      自行指定萤幕宽度而不使用目前的数值

-x                    逐行列出项目而不是逐栏列出

-X                    根据扩展名排序

-1                    每行只列出一个文件

--help            显示此帮助信息并退出

--version         显示版本信息并退出

SIZE 可以是一个可选的整数,后面跟着以下单位中的一个:

KB 1000,K 1024,MB 1000*1000,M 1024*1024,还有 G、T、P、E、Z、Y。

使用色彩来区分文件类型的功能已被禁用,默认设置和 --color=never 同时禁用了它。

使用 --color=auto 选项,ls 只在标准输出被连至终端时才生成颜色代码。

LS_COLORS 环境变量可改变此设置,可使用 dircolors 命令来设置。

退出状态:

0  正常

1  一般问题 (例如:无法访问子文件夹)

2  严重问题 (例如:无法使用命令行参数)

2、实例

[root@rudder ~]# dir

bak  tank

[root@rudder ~]# dir -l

总用量 8

drwxr-xr-x 2 root root 4096  2月 27 12:34 bak

drwxr-xr-x 4 tnak tnak 4096  2月 28 14:25 tank

Linux dip命令的用法及解释

Linux dip命令功能说明:ip拨号连接。

1、用法

dip [-aikltv][-m<MTU数目>][-p<协议>][拨号script文件]

2、补充说明

dip可控制调制解调器,以拨号IP的方式建立对外的双向连接。

3、参数

-a:询问用户名称与密码。

-i:启动拨号服务器功能。

-k:删除执行中的dip程序。

-l:指定要删除的连线,必须配合-k参数一起使用。

-m<MTU数目>:设置最大传输单位,预设值为296。

-p<协议>:设置通信协议。

-t:进入dip的指令模式。

-v:执行时显示详细的信息。

4、实例

建立拨号连接:

$ dip -t

Linux dig命令的用法及解释

Linux dig命令是常用的域名查询工具,可以用来测试域名系统工作是否正常。

1、语法

dig(选项)(参数)

2、选项

@<服务器地址>:指定进行域名解析的域名服务器;

-b<ip地址>:当主机具有多个IP地址,指定使用本机的哪个IP地址向域名服务器发送域名查询请求;

-f<文件名称>:指定dig以批处理的方式运行,指定的文件中保存着需要批处理查询的DNS任务信息;

-P:指定域名服务器所使用端口号;

-t<类型>:指定要查询的DNS数据类型;

-x<IP地址>:执行逆向域名查询;

-4:使用IPv4;

-6:使用IPv6;

-h:显示指令帮助信息。

3、参数

主机:指定要查询域名主机;

查询类型:指定DNS查询的类型;

查询类:指定查询DNS的class;

查询选项:指定查询选项。

4、实例

[root@localhost ~]# dig 域名

比如:[root@localhost ~]# dig hmxthome.com

; <<>> DiG 9.3.6-P1-RedHat-9.3.6-20.P1.el5_8.1 <<>> 域名

;; global options:  printcmd

;; Got answer:

;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 2115

;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 2, ADDITIONAL: 0

;; QUESTION SECTION:

;ywnz.com.               IN      A

;; ANSWER SECTION:

域名.        0       IN      CNAME   host.1.域名.

host.1.域名.     0       IN      A       100.42.212.8

;; AUTHORITY SECTION:

域名.            8       IN      NS      f1g1ns2.dnspod.net.

域名.            8       IN      NS      f1g1ns1.dnspod.net.

;; Query time: 0 msec

;; SERVER: 202.96.104.15#53(202.96.104.15)

;; WHEN: Thu Dec 26 11:14:37 2021

;; MSG SIZE  rcvd: 121

Linux dircolors命令的用法及解释

Linux dircolors命令设置ls命令在显示目录或文件时所用的色彩。dircolors可根据[色彩配置文件]来设置LS_COLORS环境变量或是显示设置LS_COLORS环境变量的命令。

1、语法

dircolors(选项)(参数)

2、选项

-b或--sh或--bourne-shell:显示在Boume shell中,将LS_COLORS设为目前预设置的shell指令;

-c或--csh或--c-shell:显示在C shell中,将LS_COLORS设为目前预设置的shell指令;

-p或--print-database:显示预设置;

-help:显示帮助;

-version:显示版本信息。

3、参数

文件:指定用来设置颜色的文件。

4、实例

[root@localhost ~]# dircolors -p

# Configuration file for dircolors, a utility to help you set the

# LS_COLORS environment variable used by GNU ls with the --color option.

# The keywords COLOR, OPTIONS, and EIGHTBIT (honored by the

# slackware version of dircolors) are recognized but ignored.

# Below, there should be one TERM entry for each termtype that is colorizable

TERM linux

TERM linux-c

TERM mach-color

TERM console

TERM con132x25

TERM con132x30

TERM con132x43

TERM con132x60

TERM con80x25

TERM con80x28

TERM con80x30

TERM con80x43

TERM con80x50

TERM con80x60

TERM cygwin

TERM dtterm

TERM putty

TERM xterm

TERM xterm-color

TERM xterm-debian

TERM rxvt

TERM screen

TERM screen-bce

TERM screen-w

TERM vt100

TERM Eterm

# 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

NORMAL 00 # global default, although everything should be something.

FILE 00 # normal file

DIR 01;34 # directory

LINK 01;36 # symbolic link. (If you set this to 'target' instead of a

 # numerical value, the color is as for the file pointed to.)

FIFO 40;33 # pipe

SOCK 01;35 # socket

DOOR 01;35 # door

BLK 40;33;01 # block device driver

CHR 40;33;01 # character device driver

ORPHAN 40;31;01 # symlink to nonexistent file

SETUID 37;41 # file that is setuid (u+s)

SETGID 30;43 # file that is setgid (g+s)

STICKY_OTHER_WRITABLE 30;42 # dir that is sticky and other-writable (+t,o+w)

OTHER_WRITABLE 34;42 # dir that is other-writable (o+w) and not sticky

STICKY 37;44 # dir with the sticky bit set (+t) and not other-writable

# This is for files with execute permission:

exec 01;32

# List any file extensions like '.gz' or '.tar' that you would like ls

# to colorize below. Put the extension, a space, and the color init string.

# (and any comments you want to add after a '#')

# If you use DOS-style suffixes, you may want to uncomment the following:

#.cmd 01;32 # executables (bright green)

#.exe 01;32

#.com 01;32

#.btm 01;32

#.bat 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

.deb 01;31

.rpm 01;31

.jar 01;31

# image formats

.jpg 01;35

.jpeg 01;35

.gif 01;35

.bmp 01;35

.pbm 01;35

.pgm 01;35

.ppm 01;35

.tga 01;35

.xbm 01;35

.xpm 01;35

.tif 01;35

.tiff 01;35

.png 01;35

.mov 01;35

.mpg 01;35

.mpeg 01;35

.avi 01;35

.fli 01;35

.gl 01;35

.dl 01;35

.xcf 01;35

.xwd 01;35

# audio formats

.flac 01;35

.mp3 01;35

.mpc 01;35

.ogg 01;35

.wav 01;35