文件目录命令
创建多级目录,[]代表具体参数
mkdir -p [path]
列出工作目录
pwd
递归复制
cp -r [s] [d]
查看文件命令
查看文本的前几行,-n:列出指定数目项
head sb.txt
查看文本的最后几行-n:列出指定数目项
tail sb.txt
网络工具
tcpdump
options
-
-A
Print each packet (minus its link level header) in ASCII. Handy for capturing web pages.
每个捕获到的网络数据包的内容会以 ASCII 形式输出,但会省略掉链路层(link level)的头部信息。 -
-b
Print the AS number in BGP packets in ASDOT notation rather than ASPLAIN notation.
以 ASDOT 表示法而不是 ASPLAIN 表示法打印 BGP 数据包中的 AS 编号。
打印 -
-B buffer_size
-
--buffer-size=buffer_size
Set the operating system capture buffer size to buffer_size, in units of KiB (1024 bytes).
设置操作系统捕获缓冲值为指定值,单位是1kb -
-c count
再接收指定数量数据包后退出 -
--count
Print only on stderr the packet count when reading capture file(s) instead of parsing/printing the packets. If a filter is specified on the command line, tcpdump counts only packets that were matched by the filter expression.
读取捕获文件时仅在 stderr 上打印数据包计数,而不是解析/打印数据包。如果在命令行中指定了过滤器,tcpdump只对过滤表达式匹配到的包进行计数。 -
-C file_size
Before writing a raw packet to a savefile, check whether the file is currently larger than file_size
and, if so, close the current savefile and open a new one. Savefiles after the first savefile will
have the name specified with the -w flag, with a number after it, starting at 1 and continuing upward.The units of file_size are millions of bytes (1,000,000 bytes, not 1,048,576 bytes).Note that when used with -Z option (enabled by default), privileges are dropped before opening first savefile.
在读取一个原始数据包到一个保存的文件之前,检查当前该文件是否大于file_size,如果是,则关闭当前的保存文件并打开一个新的。第一个保存文件之后的文件都通过-w flag来指定一个名字,后面跟着一个数字,并以1向上进行计数。file_size 的单位是百万字节(1,000,000 字节,而不是 1,048,576 字节)。请注意,当与 -Z 选项一起使用时(默认启用),在打开第一个保存文件之前会放弃权限。 -
-d
Dump the compiled packet-matching code in a human readable form to standard output and stop.
Please mind that although code compilation is always DLT-specific, typically it is impossible (and un‐necessary) to specify which DLT to use for the dump because tcpdump uses either the DLT of the input pcap file specified with -r, or the default DLT of the network interface specified with -i, or the par‐ticular DLT of the network interface specified with -y and -i respectively. In these cases the dump shows the same exact code that would filter the input file or the network interface without -d.However, when neither -r nor -i is specified, specifying -d prevents tcpdump from guessing a suitablenetwork interface (see -i). In this case the DLT defaults to EN10MB and can be set to another valid value manually with -y.
将编译后的数据包匹配代码以人类可读的形式转储到标准输出并停止。
请注意,尽管代码编译始终是特定于 DLT 的,但通常不可能(也没有必要)指定要使用哪个 DLT 进行转储,因为 tcpdump 要么使用 -r 指定的输入 pcap 文件的 DLT,要么使用 -i 指定的网络接口的默认 DLT,要么分别使用 -y 和 -i 指定的网络接口的特定 DLT。在这些情况下,转储显示的代码与不使用 -d 时过滤输入文件或网络接口的代码完全相同。但是,当既未指定 -r 也未指定 -i 时,指定 -d 可防止 tcpdump 猜测合适的网络接口(参见 -i)。在这种情况下,DLT 默认为 EN10MB,可以使用 -y 手动将其设置为另一个有效值。 -
-dd
Dump packet-matching code as a C program fragment.
将数据包匹配代码转储为 C 程序片段。 -
-ddd
将数据包匹配代码转储为十进制数(前面带有计数)。 -
-D
-
--list-interfaces
打印系统上可用的网络接口列表,以及 tcpdump 可以在其上捕获数据包的接口列表。对于每个网络接口,都会打印一个编号和一个接口名称,后面可能跟着该接口的文本描述。接口名称或编号可以提供给 -i 标志,以指定要捕获的接口。这在没有命令列出它们的系统上很有用(例如,Windows 系统或缺少 ifconfig -a 的 UNIX 系统);该编号在 Windows 2000 及更高版本的系统上很有用,其中接口名称是一个有点复杂的字符串。
如果 tcpdump 是使用缺少 pcap_findalldevs(3PCAP) 函数的旧版 libpcap 构建的,则不支持 -D 标志。 -
-e
Print the link-level header on each dump line. This can be used, for example, to print MAC layer ad‐dresses for protocols such as Ethernet and IEEE 802.11.
在每个转储行上打印链路级标头。例如,这可用于打印以太网和 IEEE 802.11 等协议的 MAC 层地址。 -
-E
Use spi@ipaddr algo:secret for decrypting IPsec ESP packets that are addressed to addr and contain Se‐curity Parameter Index value spi. This combination may be repeated with comma or newline separation.
使用spi@ipaddr algo:secret来解密以addr为地址并包含安全参数索引值spi的IPsec ESP的包。此组合可用逗号或换行符分隔重复。
Note that setting the secret for IPv4 ESP packets is supported at this time.
注意目前支持 设置IPv4 ESP包的密钥。
IPsec ESP:IPsec Encapsulating Security Payload。IPsec 封装安全负载(IPsec ESP)是 IPsec 体系结构中的一种主要协议,其主要设计来在 IPv4 和 IPv6 中提供安全服务的混合应用。
Algorithms may be des-cbc, 3des-cbc, blowfish-cbc, rc3-cbc, cast128-cbc, or none. The default is des-cbc. The ability to decrypt packets is only present if tcpdump was compiled with cryptography enabled.
算法可以是des-cbc, 3des-cbc, blowfish-cbc, rc3-cbc, cast128-cbc。默认是des-cbc。仅当 tcpdump 在启用加密的情况下编译时才具有解密数据包的能力。 -
-f
Print 'foreign' IPv4 addresses numerically rather than symbolically (this option is intended to get around serious brain damage in Sun's NIS server — usually it hangs forever translating non-local internet numbers).
以数字形式(而不是符号形式)打印'外部'IPv4地址。此选项旨在解决 Sun NIS 服务器中严重的脑损伤-通常它会永远挂起,翻译非本地互联网号码。
The test for 'foreign' IPv4 addresses is done using the IPv4 address and netmask of the interface on which capture is being done. If that address or netmask are not available, available, either because the interface on which capture is being done has no address or netmask or because the capture is being done on the Linux "any" interface, which can capture on more than one interface, this option will not work correctly.
对“外部” IPv4 地址的测试是使用正在进行捕获的接口的 IPv4 地址和网络掩码进行的。如果地址和子网掩码不可用,无论是因为正在捕获的接口没有地址或子网掩码,还是因为正在捕获linux下的"any"接口,该接口可以在多个接口上进行捕获,这选项将不会正常工作。
-F file
Use file as input for the filter expression. An additional expression given on the command line is ignored.
使用文件作为过滤表达式的输入,在命令行中附加的过滤表达式会被忽略。
-
-G rotate_seconds
If specified, rotates the dump file specified with the -w option every rotate_seconds seconds. Save‐files will have the name specified by -w which should include a time format as defined by strftime(3).If no time format is specified, each new file will overwrite the previous. Whenever a generated file‐name is not unique, tcpdump will overwrite the pre-existing data; providing a time specification that is coarser than the capture period is therefore not advised.
如果该选项被指定,每rotate_seconds秒对通过-w选项指定的转储文件进行旋转。保存的文件将有通过-w指定的名字,并且包含了通过strftime(3)定义的时间格式。如果没有指定的时间格式,每个新文件将会覆盖之前的文件。无论何时生成的文件名不是独一无二的,tcpdump将会覆盖之前存在的数据。不建议提供比捕获周期更粗略的时间规范。如果与 -C 选项结合使用,文件名将采用“file”的形式。 -
-h
-
--help
Print the tcpdump and libpcap version strings, print a usage message, and exit. -
--version
Print the tcpdump and libpcap version strings and exit. -
-H
Attempt to detect 802.11s draft mesh headers.
尝试检测 802.11s draft mesh headers。 -
-i interface
-
--interface=interface
Listen, report the list of link-layer types, report the list of time stamp types, or report the results of compiling a filter expression on interface. If unspecified and if the -d flag is not given, tcpdump searches the system interface list for the lowest numbered, configured up interface (excluding loop‐back), which may turn out to be, for example, ``eth0''.
监听,上报链路层类型列表,上报时间戳类型列表,或者上报接口上编译过滤表达式的结果。如果未指定且未给出 -d 标志,tcpdump 将在系统接口列表中搜索编号最小的配置接口(不包括环回),例如“eth0”。 -
-I
-
--monitor-mode
Put the interface in "monitor mode"; this is supported only on IEEE 802.11 Wi-Fi interfaces, and sup‐ported only on some operating systems.
将接口置于“监控模式”;这仅在 IEEE 802.11 Wi-Fi 接口上受支持,并且仅在某些操作系统上受支持。
examples
sudo tcpdump -e -i lo
23:30:03.837217 00:00:00:00:00:00 (oui Ethernet) > 00:00:00:00:00:00 (oui Ethernet), ethertype IPv4 (0x0800), length 66: localhost.33784 > localhost.42381: Flags [.], ack 288, win 21490, options [nop,nop,TS val 571365219 ecr 571365175], length 0。
这里的23:30:03.837217代表时间。lo表示本地环路网络(自己ping自己)。
这里的options [nop,nop,TS val 571365219 ecr 571365175] 代表的是是 TCP 数据包中的选项字段。
TS val 571365219:当前数据包发送时的时间戳,用于测量往返时间等。
TS ecr 571365175:这是对接收方上次发送的数据包中的时间戳的回显,表明发送方收到了该包。