「udevadm」-

udevadm – udev management tool

命令语法格式

udevadm [–debug] [–version] [–help]

udevadm info options

udevadm trigger [options]

udevadm settle [options]

udevadm control command

udevadm monitor [options]

udevadm test [options] devpath

udevadm test-builtin [options] command devpath

命令描述

udevadm expects a command and command specific options. It controls the runtime behavior of systemd-udevd, requests kernel events, manages the event queue, and provides simple debugging mechanisms.

命令支持的选项及含义

–debug

Print debug messages to standard error.

–version

Print version number.

-h, –help

Print help text.

udevadm info [options] [devpath|file]

Queries the udev database for device information stored in the udev database. It can also query the properties of a device from its sysfs representation to help creating udev rules that match this device.

-q, –query=TYPE

Query the database for the specified type of device data. It needs[……]

READ MORE

「sysvinit」

bootlogd 在启动期间,将所有的信息打印到系统控制台,同时记录到日志文件中。
fstab-decode 使用fstab编码的参数运行命令
halt 除非runlevel已经为0,通常使用shutdown -h,会告诉内核停止系统;它在文件/var/log/wtmp中记录系统正在关闭。
init 当内核初始化了“接管引导过程”并“启动其配置文件中指定的所有进程”的硬件时,第一个进程启动的进程。
killall5 向所有进程发送信号,除了其自身会话中的进程,因此不会杀死自己的父shell。
poweroff 告诉内核停止系统并关闭计算机(参阅halt)
reboot 告诉内核重新启动系统(参阅halt)
+runlevel 报告上一个runlevel和当前runlevel,正如/var/run/utmp中的最后一个运行级别记录所述。
shutdown 使系统以安全的方式关闭,向所有进程发出信号,并通知所有登录的用户
telinit 用于切换runlevel。该命令是指向init的软连接。[……]

READ MORE

「init」

内容:Linux下init、telinit介绍。
init用于进程控制初始化,而telinit是指向init的软链接。 init是所有进程的父母(翻译成父母进程挺奇怪的),它的主要作用是从文件/etc/inittab中存储的脚本创建进程。inittab文件中的描述条目使init在用户可登录的每一行上产生gettys,它还可以控制任何特定系统所需的自治进程。
相关引用内容:

man 8 init
https://en.wikipedia.org/wiki/Init

/sbin/init [ -a ] [ -s ] [ -b ] [ -z xxx ] [ 0123456Ss ] /sbin/telinit [ -t SECONDS ] [ 0123456sSQqabcUu ] /sbin/telinit [ -e VAR[=VAL] ]
关于RUNLEVEL相关内容,查看:《runlevel》 关于inittab的相关内容,查看:《inittab》
NAME

init, telinit – process control initialization

SYNOPSIS

/sbin/init [ -a ] [ -s ] [ -b ] [ -z xxx ] [ 0123456Ss ]
/sbin/telinit [ -t SECONDS ] [ 0123456sSQqabcUu ]
/sbin/telinit [ -e VAR[=VAL] ]

DESCRIPTION Init

Init is the parent of all processes. Its primary role is to create processes from a script stored in
the file /etc/inittab (see inittab(5)). This file usually has entries which cause init to spawn gettys
on each line that users can log in. It also controls autonomous processes required by any particular
system.

RUNLEVELS

A runlevel is a software configuration of the system which allows only a selected group of processes to
exist. Th[……]

READ MORE

「/etc/inittab」

内容: /etc/inittab文件介绍。
/etc/inittab是由sysv兼容的init进程使用的inittab文件的格式.
引用:

man 5 inittab

DESCRIPTION

The inittab file describes which processes are started at bootup and
during normal operation (e.g. /etc/init.d/boot, /etc/init.d/rc, get‐
tys…). Init(8) distinguishes multiple runlevels, each of which can
have its own set of processes that are started. Valid runlevels are
0-6 plus A, B, and C for ondemand entries. An entry in the inittab
file has the following format:

id:runlevels:action:process

Lines beginning with `#’ are ignored.

id is a unique sequence of 1-4 characters which identifies an entry

in inittab (for versions of sysvinit compiled with the old libc5
(< 5.2.18) or a.out libraries the limit is 2 characters).

Note: traditionally, for getty and other login processes, the
value of the id field is kept the same as the suffix of the cor‐
responding tty, e.g. 1 for tty1. Some ancient login accounting
programs might expect this, though I can’t think of any.

runlevels

lists the runlevels for which the specified a[……]

READ MORE

「insserv」

insserv是由update-rc.d使用的低级工具。 insserv通过读取脚本(SysV风格的init脚本)中头部的注释来获取用于创建符号链接的信息,然后使用这些信息创建符号链接。
关于SysV风格的init脚本,查看SysV风格的init脚本
insserv [-v] [-c <config>] [-p <path>] [-d] [-f] [[/]path/to/init.d/]script …
insserv [-v] [-c <config>] [-p <path>] [[/]path/to/init.d/]script[,start=<lvl1,lvl2,…>,stop=<lvl1,lvl2,…>]
insserv [-v] [-c <config>] [-p <path>] -r [-d] [-f] [[/]path/to/init.d/]script …
insserv -h
insserv支持的选项

-v, –verbose

打印但前的执行信息。

-c <config>, –config <config>

指定insserv.conf文件和insserv.conf.d目录的路径。有用的测试。

-o <path>, –override <path>

path中的LSB注释头将覆盖init.d目录中的脚本的现有LSB注释头(默认路径为/etc/insserv/overrides/)。

-p <path>, –path <path>

指定init.d文件夹的路径。

-n, –dryrun

不更新符号链接。

-r, –remove

从所有的runlevel中移出列出的脚本。

-d, –default

使用脚本中定义的默认运行级别。这可能会恢复编辑的runlevel链接方案。

-f, –force

忽略丢失的服务。除此之外,如果在命令行上指定了启动和停止级别,脚本的默认级别将被忽略。[……]

READ MORE

「runlevel」

内容:本文涉及两部分,Linux下runlevel介绍以及runlevel命令
相关引用内容:

man 8 runlevel
https://en.wikipedia.org/wiki/Runlevel

runlevel命令
runlevel用于找到以前和当前的系统运行级别
命令行语法
runlevel [utmp]

utmp utmp文件名

描述
runlevel通过读取系统的utmp文件来定位runlevel记录,然后输出用空格分割的以前和当前的runlevel。
如果之前没有runlevel,那么之前的runlevel值用N表示。如果utmp文件不存在或者没有发现runlevel记录,则输出错误并退出。
可以在RC脚本中使用runlevel命令来替代“who -r”命令。然而在新版本的init(man 8 init)中可以使用环境变量RUNLEVEL和PREVLEVEL.
Linux中的runlevel
runlevel是一个系统的软件配置,只允许存在所选择的进程组。由init为每个runlevel生成的进程是在/etc/inittab文件中定义的。 runlevel是实现Unix System V风格初始化的计算机操作系统中的一种操作模式。通常,存在七个runlevel(0~6);虽然最多可以使用10个(0-9)。S有时被用作其中一个级别的同义词。
启动时只执行一个runlevel;runlevel不是挨个地执行(比如依照按照2,3,4的顺序执行)。
runlevel的值
runlevel可以是:0–6及S(a.k.a. s,runlevels中S和s是相同的。在内部,它们是相同运行级别的别名)。
runlevels7-9也是有效的,尽管没有真正的文档记录。因为传统的UNIX版本不是用它们。
如果要修改runlevel可以使用telinit命令,telinit会发送适当的信号给init,告诉init切换到哪个runlevel,记住修改runlevel需要特权用户。关于telinit和init的介绍:查看:《telinit and init》
runlevel中S, 0, 1, 6是保留的。他们的作用如下:

runlevel S: 用在系统boot时的初始化;
runlevel 0: 用作停止(halt)系统;
runlevel 1: ‘单用户模式’,用于管理任务的模式;
runlevel 2: ‘多用户模式’,不配置网络接口,不导出网络服务。
runlevel 3: ‘有网络的多用户模式’,正常启动系统。[……]

READ MORE

「telinit」

telinit是指向init的软连接。[……]

READ MORE

「tar」

安装的可执行程序
tar Creates, extracts files from, and lists the contents of archives, also known as tarballs
参考文献

BLFS/6.68. Tar-1.29

章节列表
「tar(1)」-[……]

READ MORE

「tar(1)」-

归档程序
常用命令
解压到特定目录(使用 -C 选项):

tar -xf file.name.tar -C /path/to/directory

命令语法格式
传统风格
tar {A|c|d|r|t|u|x} [GnSkUWOmpsMBiajJzZhPlRvwo] [ARG…]
UNIX风格
tar -A [OPTIONS] ARCHIVE ARCHIVE
tar -c [-f ARCHIVE] [OPTIONS] [FILE…]
tar -d [-f ARCHIVE] [OPTIONS] [FILE…]
tar -t [-f ARCHIVE] [OPTIONS] [MEMBER…]
tar -r [-f ARCHIVE] [OPTIONS] [FILE…]
tar -u [-f ARCHIVE] [OPTIONS] [FILE…]
tar -x [-f ARCHIVE] [OPTIONS] [MEMBER…]
GNU风格
tar {–catenate|–concatenate} [OPTIONS] ARCHIVE ARCHIVE
tar –create [–file ARCHIVE] [OPTIONS] [FILE…]
tar {–diff|–compare} [–file ARCHIVE] [OPTIONS] [FILE…]
tar –delete [–file ARCHIVE] [OPTIONS] [MEMBER…]
tar –append [-f ARCHIVE] [OPTIONS] [FILE…]
tar –list [-f ARCHIVE] [OPTIONS] [MEMBER…]
tar –test-label [–file ARCHIVE] [OPTIONS] [LABEL…]
tar –update [–file ARCHIVE] [OPTIONS] [FILE…]
tar –update [-f ARCHIVE] [OPTIONS] [FILE…]
tar {–extract|–get} [-f ARCHIVE] [OPTIONS] [MEMBER…]
命令描述
GNU tar是一个归档程序,旨在将多个文件存储在单个文件(存档)中,并操作此类存档。存档可以是常规文件或设备(例如磁带驱动器,因此是程序的名称,代表磁带存档器),它可以位于本地或远程计算机上。
选项风格
GNU tar的选项可以以三种不同的样式给出:
在传统风格[……]

READ MORE

「tcpdump」

TCPDump,用于dump网络流量,支持IPv4, ICMPv4, IPv6, ICMPv6, UDP, TCP, SNMP, AFS, BGP, RIP, PIM, DVMRP, IGMP, SMB, OSPF, NFS等其他很多协议。
安装
从发行版的源中安装

#!/bin/bash

apt-get install tcpdump

从源码编译安装 项目地址:https://github.com/the-tcpdump-group/tcpdump 安装过程参考源码目录下的INSTALL.txt文件
安装的可执行程序
tcpdump 用于dump网络数据流量。
参考文献

Homepage: http://www.tcpdump.org/
Wikipedia/tcpdump: https://en.wikipedia.org/wiki/Tcpdump[……]

READ MORE

「manual」

tcpdump – dump traffic on a network
SYNOPSIS
tcpdump [ -AbdDefhHIJKlLnNOpqStuUvxX# ] [ -B buffer_size ]

[ -c count ]
[ -C file_size ] [ -G rotate_seconds ] [ -F file ]
[ -i interface ] [ -j tstamp_type ] [ -m module ] [ -M secret ]
[ –number ] [ -Q in|out|inout ]
[ -r file ] [ -V file ] [ -s snaplen ] [ -T type ] [ -w file ]
[ -W filecount ]
[ -E spi@ipaddr algo:secret,… ]
[ -y datalinktype ] [ -z postrotate-command ] [ -Z user ]
[ –time-stamp-precision=tstamp_precision ]
[ –immediate-mode ] [ –version ]
[ expression ]

DESCRIPTION
Tcpdump prints out a description of the contents of packets on a network interface that match the boolean expression; the description is preceded by a time stamp, printed, by default, as hours, minutes, seconds, and fractions of a second since midnight. It can also be run with the -w flag, which causes it to save the packet data to a file for later analysis, and/or with the -r flag, which causes it to read from a saved packet file rather than to read packets from a network interface. It can also be run with the -V flag, which causes it to read a list of saved packet files. In all cases,[……]

READ MORE

「pcap-filter」

pcap-filter – packet filter syntax
DESCRIPTION

pcap_compile() is used to compile a string into a filter program. The resulting filter program can then be
applied to some stream of packets to determine which packets will be supplied to pcap_loop(), pcap_dis‐
patch(), pcap_next(), or pcap_next_ex().

The filter expression consists of one or more primitives. Primitives usually consist of an id (name or num‐
ber) preceded by one or more qualifiers. There are three different kinds of qualifier:

type type qualifiers say what kind of thing the id name or number refers to. Possible types are host, net

, port and portrange. E.g., `host foo’, `net 128.3′, `port 20′, `portrange 6000-6008′. If there is
no type qualifier, host is assumed.

dir dir qualifiers specify a particular transfer direction to and/or from id. Possible directions are

src, dst, src or dst, src and dst, ra, ta, addr1, addr2, addr3, and addr4. E.g., `src foo’, `dst net
128.3′, `src or dst port ftp-data’. If there is no dir qualifier, src or dst is assumed. The ra,
ta, addr1, addr2, addr3, and addr4 qualifiers are only valid f[……]

READ MORE

「tcpdump」- 转储网络流量

常用命令
根据协议抓取:

# tcpdump -n -i eth0 not proto \\carp

# tcpdump -i eth0 ip[9] == 89 # OSPF
# tcpdump -i eth0 proto ospf

抓取某个网段(debian – tcpdump ip range):

# tcpdump net 130.190.0.0/17

命令语法格式

tcpdump [ -AbdDefhHIJKlLnNOpqStuUvxX# ] [ -B buffer_size ]
[ -c count ]
[ -C file_size ] [ -G rotate_seconds ] [ -F file ]
[ -i interface ] [ -j tstamp_type ] [ -m module ] [ -M secret ]
[ –number ] [ -Q in|out|inout ]
[ -r file ] [ -V file ] [ -s snaplen ] [ -T type ] [ -w file ]
[ -W filecount ]
[ -E spi@ipaddr algo:secret,… ]
[ -y datalinktype ] [ -z postrotate-command ] [ -Z user ]
[ –time-stamp-precision=tstamp_precision ]
[ –immediate-mode ] [ –version ]
[ expression ]

命令描述

Tcpdump prints out a description of the contents of packets on a network interface that match the boolean expression; the description is preceded by a time stamp, printed, by default, as hours, minutes, seconds, and fractions of a second since midnight. It can also be run with the -w flag, which causes it to save the packet data to a file for later analysis, and/or with the -r flag, which cau[……]

READ MORE

「texinfo」

info Used to read info pages which are similar to man pages, but often go much deeper than just explaining all the available command line options [For example, compare man bison and info bison.]
install-info Used to install info pages; it updates entries in the info index file
makeinfo Translates the given Texinfo source documents into info pages, plain text, or HTML
pdftexi2dvi Used to format the given Texinfo document into a Portable Document Format (PDF) file
pod2texi Converts Pod to Texinfo format
texi2any Translate Texinfo source documentation to various other formats
texi2dvi Used to format the given Texinfo document into a device-independent file that can be printed
texi2pdf Used to format the given Texinfo document into a Portable Document Format (PDF) file
texindex Used to sort Texinfo index files
参考文献

LFS/6.68. Texinfo-6.1[……]

READ MORE

「info(1)」-

读取Info文档
命令语法格式
info [OPTION]… [MENU-ITEM…]
命令描述
在Info格式中读取文档。
命令支持的选项及含义
-a, –all 使用所有匹配的手册。
-k, –apropos=STRING 在所有手册的所有索引中查找STRING。
-d, –directory=DIR 将DIR添加到INFOPATH中。
-f, –file=MANUAL 指定要查看的Info手册MANUAL。
–index-search=STRING 转到索引条目STRING指向的节点。
-n, –node=NODENAME 指定首次访问的Info文件中的节点
-o, –output=FILE 将所选节点输出到FILE
-O, –show-options, –usage 转到命令行选项节点。
–subnodes 递归输出菜单项目。
-v, –variable VAR=VALUE 将Info变量VAR的值设置为VALUE。
-w, –where, –location 打印Info文件的物理位置
–version 显示版本信息并退出。
-h, –help 显示帮助信息并退出。
注意事项
第一个非选项参数(如果存在)是要开始的菜单项;在INFOPATH的所有’dir’文件中搜索它。如果它不存在,info将合并所有’dir’文件并显示结果。 任何剩余的参数都被视为菜单项的名称(相对于访问的初始节点的)。
有关按键绑定的摘要,请在Info中输入H键。
使用示例
显示顶级的DIR目录:

# info

显示该Info程序的手册:

# info info-stnd

从顶级DIR开始emacs节点:

# info emacs

选择emacs手册中的buffers菜单条目:

# info emacs buffers

起始于emacs手册的Files节点:

# info emacs -n Files
# info ‘(emacs)Files’

起始于emacs的命令行选项节点:

# info –show-options emacs

将整个emacs手册转储到out.txt中:

# info –subnodes -o out.txt emacs

显示./foo.info文件,而不是搜索DIR:

# info -f ./[……]

READ MORE

「time」

time
参考文献

BLFS/Time-1.7

章节列表
「time(1)」-[……]

READ MORE

「time(1)」-

运行程序并总结系统资源使用情况
命令语法格式
time [ -apqvV ] [ -f FORMAT ] [ -o FILE ] COMMAND [ ARGS ]
命令描述
命令time使用任何给定参数ARG运行程序COMMAND。当COMMAND完成时,time显示有关COMMAND使用的资源的信息(默认情况下,在标准错误输出上)。 如果COMMAND以非零状态退出,则time显示警告消息和退出状态。
命令time从字符串FORMAT中确定显示有关COMMAND使用的资源的信息。如果在命令行上未指定格式,但设置了TIME环境变量,则将其值用作格式。 否则,使用内置于time的默认格式。
命令time的选项必须出现在COMMAND之前的命令行中。在COMMAND之后的命令行上的任何内容都作为参数传递给COMMAND。
命令支持的选项及含义
-o FILE, –output=FILE 将资源使用统计信息写入FILE,而不是标准错误。 默认情况下,这会覆盖文件,从而破坏文件的先前内容。对于收集有关“在标准错误上生成输出程序”和“交互式程序”的信息,此选项非常有用。
-a, –append 将资源使用信息附加到输出文件而不是覆盖它。 此选项仅适用于`-o’或`–output’选项。
-f FORMAT, –format FORMAT 使用FORMAT作为控制时间输出的格式字符串。 请参阅以下更多信息。
-p, –portability 使用以下格式字符串,以符合POSIX标准1003.2:

real %e
user %U
sys %S

-v, –verbose 使用内置的详细格式,该格式在其单独的行上显示有关程序资源使用的每条可用信息,并带有其含义的英文描述。
–quiet 不要报告程序的状态,即使是非零状态。
-V, –version 显示版本信息并退出。
–help 显示帮助信息并退出。
格式化输出
格式字符串FORMAT控制time输出的内容。可以使用`-f’或`–format’为选项-v(–verbose)、-p(–portability)设置格式字符串。 如果未给出它们,但设置了TIME环境变量,则将其值用作格式字符串。 否则,使用内置的默认格式。 默认格式为:

%Uuser %Ssystem %Eelapsed %PCPU (%Xtext+%Ddata %Mmax)k
%Iinputs+%Ooutputs (%Fmajor+%Rminor)pagefaults %Wswaps

格式字符串通常由散布的“资源说明符”和有[……]

READ MORE

「unzip」

安装的可执行程序
funzip allows the output of unzip commands to be redirected.
unzip lists, tests or extracts files from a ZIP archive.
unzipfsx is a self-extracting stub that can be prepended to a ZIP archive. Files in this format allow the recipient to decompress the archive without installing UnZip.
zipgrep searches files in a ZIP archive for lines matching a pattern.
zipinfo produces technical information about the files in a ZIP archive, including file access permissions, encryption status, type of compression, etc.
参考文献

BLFS/UnZip-6.0[……]

READ MORE

「zipgrep(1)」-

在ZIP存档中搜索与模式匹配的行的文件
命令语法格式
zipgrep [egrep_options] pattern file[.zip] [file(s) …] [-x xfile(s) …]
命令描述
命令zipgrep将在ZIP存档中搜索与给定字符串或模式匹配的行。zipgrep是一个Shell脚本,需要egrep(1)和unzip(1)才能运行。其输出与egrep(1)的输出相同。
命令支持的选项及含义
ZIP存档文件名之前的所有选项都传递给egrep(1)。
[egrep_options] 传递给egrep的选项。
pattern 位于ZIP存档中的模式。可以使用egrep(1)接受的任何字符串或正则表达式。
file[.zip] ZIP存档的路径。(不支持ZIP存档名称的通配符表达式。)如果找不到文字文件名,则追加后缀.zip。请注意,与任何其他ZIP存档一样,支持自解压ZIP文件;只需明确指定.exe后缀(如果有)。
[file(s)] 要处理的可选的归档成员列表,以空格分隔。如果未指定任何成员文件,则会搜索ZIP存档的所有成员。正则表达式(通配符)可用于匹配多个成员:

*,匹配0个或更多字符的序列
?,匹配一个字符
[…],匹配括号内的任何单个字符;范围由起始字符,连字符和结束字符指定。如果感叹号或插入符号(“!”或“^”)在左括号后面,则括号内的字符范围将被补充(即除括号内的字符外的任何内容都被视为匹配)。

请务必引用可能由Shell解释或修改的任何字符。
[-x xfile(s)] 要从处理中排除的可选归档成员列表。由于通配符与目录分隔符(`/’)匹配,因此该选项可用于排除子目录中的所有文件。例如,zipgrep grumpy foo *.[ch] -x */*将在“foo”存档的主目录中的所有C源文件中搜索字符串“grumpy”,但不会在任何子目录中进行搜索。如果没有-x选项,将搜索zipfile中所有目录中的所有C源文件。
相关手册
egrep(1), unzip(1), zip(1), funzip(1), zipcloak(1), zipinfo(1), zipnote(1), zipsplit(1)
The Info-ZIP home page is currently at http://www.info-zip.org/pub/infozip ftp://ftp.info-zip.org/pub/infozip
参考文献

man 1 zipgrep, Version 6.0-21

更新日志

09/2[……]

READ MORE

「zipinfo(1)」-

列出ZIP归档的详细信息
命令语法格式
zipinfo [-12smlvhMtTz] file[.zip] [file(s) …] [-x xfile(s) …]
unzip -Z [-12smlvhMtTz] file[.zip] [file(s) …] [-x xfile(s) …]
命令描述
zipinfo列出了有关ZIP存档中文件的技术信息,最常见于MS-DOS系统。这样的信息包括文件访问权限、加密状态、压缩类型、版本、操作系统或压缩程序的文件系统等。默认行为(没有选项)是列出存档中每个文件,每文件对应一行条目,由标题、尾部行提供整个存档的摘要信息。格式是Unix的“ls -l”和“unzip -v”输出结果的交叉。参见下面的描述。
请注意,zipinfo与unzip是相同的程序(在Unix下,是指向它的链接);但是,在某些系统上,编译unzip时可能省略了zipinfo支持。
命令行参数
file[.zip] ZIP存档的路径。如果file是通配符,则按操作系统(或文件系统)确定的顺序处理每个匹配的文件。只有文件名可以是通配符;路径本身不能。
通配符表达式类似于Unix egrep(1)(常规)表达式,可能包含:

*,匹配0个或更多字符的序列
?,匹配一个字符
[…],匹配括号内的任何单个字符;范围由起始字符,连字符和结束字符指定。如果感叹号或插入符号(“!”或“^”)在左括号后面,则括号内的字符范围将被补充(即除括号内的字符外的任何内容都被视为匹配)。要指定逐字左括号,必须使用序列“[[]”。

请务必引用可能由Shell解释或修改的任何字符,特别是在Unix和VMS下。如果未找到匹配项,则假定file是文字文件名;如果失败,则附加后缀.zip。请注意,与任何其他ZIP存档一样,支持自解压ZIP文件;只需明确指定.exe后缀(如果有)。
[file(s)] 要处理的可选的归档成员列表,以空格分隔。(使用VMSCLI定义编译的VMS版本必须使用逗号分隔文件。)正则表达式(通配符)可用于匹配多个成员;参考之前的说明。同样,请务必引用可由Shell扩展或修改的表达式。
[-x xfile(s)] 要从处理中排除的可选归档成员列表。
命令支持的选项及含义
-1 仅列出文件名,每行一个。此选项排除所有其他选项;从不打印标题、尾部、zipfile注释。它适用于Unix Shell脚本。
-2 列表文件名,每行一个,但允许标题(-h),尾部(-t),ZIP文件注释(-z)。如果存储的文件名特别长,则此选项可能很有用。
-s 以简短的Unix的“ls -l”格式列出ZIP文件信息。这是默[……]

READ MORE

「usbutils」

USB Utils,包含了一些程序,这些程序用于显示系统中的USB总线的有关信息和连接到它们的设备的信息。
安装
从发行版的源中安装

#!/bin/bash

# Kali GNU/Linux Rolling
apt-get install usbutils

从源码中编译安装 参考BLFS/usbutils-008
安装的可执行程序
lsusb 输出USB总线信息和连接到总线上的设备的信息,输出信息可读性并不高;
lsusb.py 和 lsusb 一样,但是输出信息的可读性高; 该命令在Kali GNU/Linux Rolling的usbutils软件包中并不存在。
usb-devices SHELL脚本,作用于lsusb是一样的。该脚本使为了防止/proc/bus/usb/devices不可用的情况;
usbhid-dump 用于从USB设备的HID(human interface device)接口转储报告描述符和流。
update-usbids 用于更新usb.ids文件,该文件命令只在某些Linux发行版中存在。
参考文献

BLFS/usbutils-008
下载usbutils软件包[……]

READ MORE

「lsusb(8)」-

列出USB设备
命令语法格式
lsusb [ options ]
命令描述
命令usb输出USB总线的信息和连接到总线上的设备的信息。
命令支持的选项及含义
-s [[bus]:][devnum] 只显示指定bus或者devnum的设备。给出10进制数值会被忽略。
-d [vendor]:[product] 只显示指定VendorID和ProductID的设备。给出的ID为16进制。
-D device 不扫描/dev/bus/usb目录,只打印device参数指定的设备的信息。参数device的值应该是像/dev/bus/usb/001/001样子的。该选项打印的是详细信息,像-v选项;必须使用root权限来执行。
-t 转储物理USB设备树形结构。该选项会覆盖-v选项。
-v, –verbose 显示设备的详细信息。这包括设备的当前速度的配置描述符。用于USB设备类的类别描述符也会显示出来,包括hub, audio, HID, communications, chipcard。
-V, –version 打印版本信息并退出,返回成功。
相关文件
/var/lib/usbutils/usb.ids 列出所有已知USB设置的ID(vendors, products, classes, subclasses, protocols)。
退出状态
>0 指定的设备未找到
相关手册
lspci(8), usbview(8).
参考文献

man 8 lsusb, Version 1007-4+b1

更新日志

01/19/2017 创建文章
10/03/2018 修改文章内容[……]

READ MORE

「update-usbids」

update-usbids,下载最新的USB ID列表,并安装。
命令行语法格式
update-usbids
命令行选项及含义
-q 安静模式、不打印任何输出,除了错误。
相关文件
/var/lib/usbutils/usb.ids.gz 最新的USB ID文件的安装位置。文件usb.ids的下载地址为:http://www.linux-usb.org/usb.ids 该命令需要wget或者lynx。如果支持gzip或者bzip2,将自动下载压缩的文件。
关于usb.ids文件 该文件是已知的USB ID的列表,它一个数据库文件,里面保存了VendorID和DeviceID相关的详细信息,包含vendors, products, classes, subclasses, protocols。 因为这个文件的存在,在lsusb的时候才能显示USB总线及设备的详细信息,如下图(省略部分内容):
如果该文件不存在,是看不到相关描述信息的,还会给个错误,如下图:
相关文档
lsusb(8)
参考文献

man 8 update-usbids, version usbutils-007[……]

READ MORE

「util-linux」

Util-linux,该软件包中包含了繁杂的命令。这些命令用于文件系统、控制台、分区和信息。
安装的命令列表
addpart,Informs the Linux kernel of new partitions agetty,Opens a tty port, prompts for a login name, and then invokes the login program blkdiscard,Discards sectors on a device blkid,A command line utility to locate and print block device attributes blockdev,Allows users to call block device ioctls from the command line cal,Displays a simple calendar cfdisk,Manipulates the partition table of the given device chcpu,Modifies the state of CPUs chrt,Manipulates real-time attributes of a process col,过滤掉反向换行符号。 colcrt,Filters nroff output for terminals that lack some capabilities, such as overstriking and half-lines colrm,Filters out the given columns column,Formats a given file into multiple columns ctrlaltdel,Sets the function of the Ctrl+Alt+Del key combination to a hard or a soft reset delpart,Asks the Linux kernel to remove a partition dmesg,Dumps the kernel boot messages eject,Ejects removable media fallocate,Preallocates space to a file fdformat,Low-level formats a floppy disk fdisk,Manipulates the partition table of the given device findfs,Finds a file system by label or Universally Unique Identifier (UUID) findmnt,Is a[……]

READ MORE

「addpart(8)」-

告诉内核有关分区的存在
命令语法格式
addpart device partition start length
命令描述
命令addpart告诉Linux内核有关指定分区的存在。该命令是ioctl(2)“添加分区”的简单包装。
此命令不会操作块设备上的分区。
命令参数
device 磁盘设备。
partition 分区号。
start 分区的开始。以512字节的扇区为单位。
length 分区的长度。以512字节的扇区为单位。
相关手册
delpart(8), fdisk(8), parted(8), partprobe(8), partx(8)
参考文献

man 8 addpart, Version addpart from util-linux 2.32

更新日志

07/12/2018 创建文章[……]

READ MORE

「blkdiscard(8)」-

丢弃设备上的扇区
命令语法格式
blkdiscard [options] [-o offset] [-l length] device
命令描述
命令blkdiscard用于丢弃设备扇区。这对于固态驱动程序(SSD)和精简配置存储非常有用。与fstrim(8)不同,此命令直接在块设备上使用。
默认情况下,命令blkdiscard将丢弃设备上的所有块。可以通过使用选项来进行基于范围或大小的修改行为,如下所述。
警告:设备上被丢弃区域中的所有数据都将丢失!
命令支持的选项及含义
device 块设备的路径名。
-o, –offset offset 在设备中开始丢弃的起始位置。提供的值将与设备扇区大小对齐。默认值为零。
-l, –length length 要丢弃的字节数(从起点offset开始计算)。提供的值将与设备扇区大小对齐。如果指定的值超出设备的结尾,则blkdiscard将停在该设备大小边界。默认值为到设备结尾。
-p, –step length 一次迭代中要丢弃的字节数。默认是一次ioctl(2)调用丢弃所有。
-s, –secure 执行安全丢弃。安全丢弃与常规丢弃相同,但是在安全擦除中可能由垃圾收集创建的丢弃块的所有副本也会被擦除。这需要来自设备的支持。
-z, –zeroout 使用零字节填充,而不是擦除。
-v, –verbose 显示offset和length的对齐值,因为这两个值将与设备扇区大小对齐,所以与指定的值会有所出入。如果指定了–step选项,则每秒打印一次丢弃执行的进度。
–help 显示帮助信息并退出。
–version 显示版本信息并退出。
offset, length 这两个参数后面紧跟单位KiB(=1024),MiB(=1024 * 1024),依此类推还有GiB,TiB,PiB,EiB,ZiB,YiB(其中,“iB”是可选的,例如 ,“K”与“KiB”具有相同的含义)。
也可以后跟KB(= 1000),MB(= 1000 * 1000),以此类推还有GB,TB,PB,EB,ZB,YB等。
相关手册
fstrim(8)
参考文献

man 8 blkdiscard, Version blkdiscard from util-linux 2.32

更新日志

07/11/2018 创建文章[……]

READ MORE

「blkid」-

blkid – locate/print block device attributes

命令语法格式

blkid –label label | –uuid uuid

blkid [–no-encoding –garbage-collect –list-one –cache-file file] [–output format] [–match-tag tag] [–match-token NAME=value]

[device …]

blkid –probe [–offset offset] [–output format] [–size size] [–match-tag tag] [–match-types list] [–usages list] device …

blkid –info [–output format] [–match-tag tag] device …

命令描述

The blkid program is the command-line interface to working with the libblkid(3) library. It can determine the type of content (e.g.
filesystem or swap) that a block device holds, and also the attributes (tokens, NAME=value pairs) from the content metadata (e.g.
LABEL or UUID fields).

It is recommended to use lsblk(8) command to get information about block devices, or lsblk –fs to get an overview of filesystems, or
findmnt(8) to search in already mounted filesystems.

lsblk(8) provides more information, better control on output formatting, easy to use in scripts and it does not require root
permissions to get actual informatio[……]

READ MORE

「blockdev」-

blockdev – call block device ioctls from the command line

命令语法格式

blockdev [-q] [-v] command [command…] device [device…]
blockdev –report [device…]
blockdev -h|-V

命令描述

The utility blockdev allows one to call block device ioctls from the command line.

命令支持的选项及含义

-q Be quiet.

-v Be verbose.

–report

Print a report for the specified device. It is possible to give multiple devices. If none is given, all devices which appear in /proc/partitions are shown. Note that the partition StartSec is in 512-byte sectors.

-h, –help

Display help text and exit.

-V, –version

Print version and exit.

COMMANDS

It is possible to give multiple devices and multiple commands.

–flushbufs

Flush buffers.

–getalignoff

Get alignment offset.

–getbsz

Print blocksize in bytes.

–getdiscardzeroes

Get discard zeroes support status.

–getfra

Get filesystem readahead in 512-byte sectors.

–getiomin[……]

READ MORE

「cal(1)」-

显示日历和复活节的日期
命令语法格式
cal [-31jy] [-A number] [-B number] [-d yyyy-mm] [[month] year]
cal [-31j] [-A number] [-B number] [-d yyyy-mm] -m month [year]
ncal [-C] [-31jy] [-A number] [-B number] [-d yyyy-mm] [[month] year]
ncal [-C] [-31j] [-A number] [-B number] [-d yyyy-mm] -m month [year]
ncal [-31bhjJpwySM] [-A number] [-B number] [-H yyyy-mm-dd] [-d yyyy-mm] [-s country_code] [[month] year]
ncal [-31bhJeoSM] [-A number] [-B number] [-d yyyy-mm] [year]
命令描述
命令cal以传统格式显示简单日历,ncal提供另一种布局,更多选项和复活节日期。新的格式有点局促,但它可以在25×80终端中显示一年。 如果未指定参数,则显示当前月份。
命令行选项
-h 关闭今天的突出显示。
-J 显示朱利安日历,如果与-o选项结合使用,则根据朱利安日历显示东正教复活节的日期。
-e 显示复活节的日期(西方教会)。
-j 显示朱利安日(基于第一天,从1月1日开始编号)。
-m month 显示指定的月份。 如果将month指定为十进制数字,则附加“f”或“p”将分别显示下一年或上一年的同一月份。
-o 显示东正教复活节(希腊和俄罗斯东正教教会)的日期。
-p 打印国家代码,并将天数从朱利安日历转换为格里高利日历,因为它们由ncal假设。 从本地环境确定的国家/地区代码标有星号。
-s country_code 假设在与country_code关联的日期从Julian切换到Gregorian日历。 如果没有指定,ncal会尝试从当地环境猜测切换日期或者回到1752年9月2日。这是英国和她的殖民地切换到公历的时候。
-w 打印每周列以下的周数。
-y 显示指定年份的日历。 如果在命令行上指定了一年但没有指定月份,则隐含此选项。
-3 显示今天的前一个,当前和下个月。
-1 仅显示当前月份。 这是默认值。
-A number 添加的后几个月。 指定的月数将添加到显示的末尾。 这是由-y,-3,-1选项选择的任何日期范围的补充。 例如,“cal -y -B2 -A2”显示从上一[……]

READ MORE

「cfdisk」-

cfdisk – display or manipulate a disk partition table

命令语法格式

cfdisk [options] [device]

命令描述

cfdisk is a curses-based program for partitioning any block device. The default device is /dev/sda.

Note that cfdisk provides basic partitioning functionality with a user-friendly interface. If you need advanced features, use fdisk(8) instead.

Since version 2.25 cfdisk supports MBR (DOS), GPT, SUN and SGI disk labels, but no longer provides any functionality for CHS (Cylinder-Head-Sector) addressing. CHS has never been important for Linux, and this addressing
concept does not make any sense for new devices.

Since version 2.25 cfdisk also does not provide a ‘print’ command any more. This functionality is provided by the utilities partx(8) and lsblk(8) in a very comfortable and rich way.

If you want to remove an old partition table from a device, use wipefs(8).

命令支持的选项及含义

-h, –help

Display help text and exit.

-L, –color[=when]

Colorize the output. The optional argument when can be auto, never or always. If the when argument is omitted, it[……]

READ MORE