Relative Content

LINUX MANUAL PAGES

category

「systool(1)」-

通过总线、类、拓扑来查看系统设备信息
命令语法格式
systool [options [device]]
命令描述
调用不带参数的systool将显示所有可用的总线类型、设备类、根设备。
提供device时,仅显示指定设备的选项所需信息,否则将显示所有当前设备。
命令systool使用libsysfs提供的API来收集信息。命令systool仅在运行内核2.5或更高版本的Linux系统上运行,并且安装了sysfs文件系统。
命令支持的选项及含义
-a 显示所请求资源的属性
-b bus 显示特定总线的信息
-c class 显示特定类的信息
-d 只显示设备
-m module_name 显示特定模块的信息
-p 显示资源的绝对sysfs路径
-v 显示包含值的所有属性
-A attribute 显示所请求资源的属性值
-D 只显示驱动
-P 显示设备的父设备
-h 显示使用信息
相关手册
The web page of libsysfs at http://linux-diag.sourceforge.net/Sysfsutils.html
参考文献

man 1 systool, Version 2.1.0+repack-4+b2

更新日志

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

READ MORE

「sysstat」

Sysstat,软件包包含了一些用于监视系统性能和使用活动的命令程序。Sysstat包含常见于许多商业Unix的sar程序及可以通过cron计划来收集和历史化性能和活动数据的工具。
安装
从发行版的源中安装

#!/bin/sh

# Ubuntu 16.04.2 LTS
apt-get install sysstat

从源码中安装 参考BLFS7.10/Sysstat-11.4.0: http://www.linuxfromscratch.org/blfs/view/7.10/general/sysstat.html
安装的命令列表
cifsiostat 报告CIFS文件系统上的IO统计数据。
iostat 报告CPU的统计数据,以及设备和分区的IO的统计数据。
mpstat 每个可用的处理器的写活动。
pidstat 用于监控当前由Linux Kernel管理的各项任务。
sadf 用于显示由sar命令创建的数据文件的内容。但与sar不同的是,sadf可以以许多不同的格式编写数据。
sar 用于显示操作系统中选定的累积活动计数器的内容。
tapestat 用于监视连接到系统的磁带驱动器的活动。
参考文献

BLFS/Sysstat-11.4.0
SYSSTAT Home Page: http://sebastien.godard.pagesperso-orange.fr/[……]

READ MORE

「iostat(1)」-

报告设备和分区的CPU统计信息和输入/输出统计信息
命令语法格式
iostat [ -c ] [ -d ] [ -h ] [ -k | -m ] [ -N ] [ -t ] [ -V ] [ -x ] [ -y ] [ -z ] [ -j { ID | LABEL | PATH | UUID | … } ] [ [ -H ] -g group_name ] [ -p [ device [,…] | ALL ] ] [ device […] | ALL ] [ interval [ count ] ]
命令描述
命令iostat用于通过观察设备相对于其平均传输速率的活动时间来监视系统输入/输出设备负载。命令iostat生成可用于更改系统配置的报告,以更好地平衡物理磁盘之间的输入/输出负载。
命令iostat生成的第一个报告提供了有关自系统引导以来的时间的统计信息,除非使用了-y选项(在这种情况下,省略了第一个报告)。每个后续报告都涵盖自上次报告以来的时间。每次运行iostat命令时都会报告所有统计信息。该报告由一个CPU标题行和一行CPU统计信息组成。在多处理器系统上,CPU统计信息在系统范围内计算为所有处理器之间的平均值。将显示设备标题行,然后显示已配置的每个设备的统计信息行。
参数interval指定每个报告之间的时间量(以秒为单位)。参数count可以与interval参数一起指定。如果指定了count参数,则count的值确定以间隔秒间隔生成的报告数。如果指定了interval参数而没有count参数,则iostat命令会连续生成报告。
命令支持的选项及含义
-c 仅显示CPU的使用率报告。
-d 仅显示存储设备的使用率报告。
-g group_name { device […] | ALL } 显示一组设备的统计信息。命令iostat报告列表中每个单独设备的统计信息,然后显示以group_name为名的全局统计信息,并由列表中的所有设备组成。关键词ALL意味着系统定义的所有块设备都应包含在组中。
-H 此选项必须与选项-g一起使用,并指示仅显示组的全局统计信息,而不显示组中各个设备的统计信息。使用选项-h隐式启用此选项。
-h 已更加易读的方式显示设备使用率。
-j { ID | LABEL | PATH | UUID | … } [ device […] | ALL ] 显示持久的设备名称。选项(ID,LABEL等)指定持久名称的类型。这些选项不受限制,唯一的条件是具有所需持久性名的目录存在于/dev/disk中。可以在所选择的持久名称类型中指定多个设备。因为持久的设备名称通常很长的选项。
-k 以kb为单位显示统计数据。[……]

READ MORE

「mpstat(1)」-

功能简述
报告处理器相关的统计数据
常用命令
在所有处理器中,以两秒为间隔,显示五个全局统计报告:

# mpstat 2 5

以两秒为间隔显示所有处理器的五个统计报告:

# mpstat -P ALL 2 5

语法格式

mpstat [ -A ] [ -u ] [ -V ] [ -I { keyword [,…] | ALL } ] [ -P { cpu [,…] | ON | ALL } ] [ interval [ count ] ]

命令描述
命令mpstat先的标准输写入每个可用处理器出活动,处理器0是第一个。还报告了所有处理器之间的全局平均活动。命令mpstat可以在SMP和UP机器上使用,但在后者中,只打印全局平均活动。 如果未选择任何活动,则默认报告为CPU利用率报告。
参数interval指定每个报告之间的时间量(以秒为单位)。值0(或根本没有参数)表示自系统启动(引导)以来报告处理器统计信息的时间。如果此参数未设置为零,则可以将count参数与interval参数一起指定。 count的值确定以间隔秒间隔生成的报告数。如果指定了interval参数而没有count参数,则mpstat命令会连续生成报告。
命令选项
-A 等价于-u -I ALL -P ALL的组合。
-P { cpu [,…] | ON | ALL } 指示要报告统计信息的处理器编号。参数cpu是处理器号。请注意,处理器0是第一个处理器。关键字ON表示要为每个在线处理器报告统计信息,而ALL关键字表示要为所有处理器报告统计信息。
-I { keyword [,…] | ALL } 报告中断统计信息。可用的关键字有:SUM, CPU, SCPU
使用SUM关键字,命令mpstat报告每个处理器的中断总数。 将显示以下值:

CPU,处理器编号。关键字ALL表示统计数据计算为所有处理器之间的平均值。
intr/s,显示CPU每秒接收的中断总数。

使用CPU关键字,将显示CPU每秒接收的每个中断的数量。 中断是/proc/interrupts中列出的中断。
使用SCPU关键字,显示CPU每秒接收的每个软中断的数量。 此选项仅适用于内核2.6.31及更高版本。 软中断是/proc/softirqs中列出的那些。
关键字ALL相当于指定上面的所有关键字,因此显示所有中断统计信息。
-u 报告CPU利用率。将显示以下值:

CPU,处理器编号。关键字All表示统计数据计算为所有处理器之间的平均值。
%usr,显示在用户级别(应用程序)执行时发[……]

READ MORE

「pidstat」

pidstat,报告Linux任务的统计。

The pidstat command is used for monitoring individual tasks currently being managed by the Linux kernel. It
writes to standard output activities for every task selected with option -p or for every task managed by the
Linux kernel if option -p ALL has been used. Not selecting any tasks is equivalent to specifying -p ALL but
only active tasks (tasks with non-zero statistics values) will appear in the report.

The pidstat command can also be used for monitoring the child processes of selected tasks. Read about option
-T below.

The interval parameter specifies the amount of time in seconds between each report. A value of 0 (or no
parameters at all) indicates that tasks statistics are to be reported for the time since system startup
(boot). The count parameter can be specified in conjunction with the interval parameter if this one is not
set to zero. The value of count determines the number of reports generated at interval seconds apart. If the
interval parameter is specified without the count parameter, the pidstat command generates reports continu‐
ously.

You can select[……]

READ MORE

「systemd」

What is this?
systemd is a suite of basic building blocks for a Linux system. It provides a system and service manager that runs as PID 1 and starts the rest of the system. systemd provides aggressive parallelization capabilities, uses socket and D-Bus activation for starting services, offers on-demand starting of daemons, keeps track of processes using Linux control groups, maintains mount and automount points, and implements an elaborate transactional dependency-based service control logic. systemd supports SysV and LSB init scripts and works as a replacement for sysvinit. Other parts include a logging daemon, utilities to control basic system configuration like the hostname, date, locale, maintain a list of logged-in users and running containers and virtual machines, system accounts, runtime directories and settings, and daemons to manage simple network configuration, network time synchronization, log forwarding, and name resolution. See Lennart’s blog story for a longer introduction, and the three status updates since then. Also see the Wikipedia article. If you are wondering whether systemd is for you, please have a look at this comparison of init systems by one of the crea[……]

READ MORE

「halt(8)」-

关闭、断电、重启计算机
命令语法格式
halt [OPTIONS…]
poweroff [OPTIONS…]
reboot [OPTIONS…]
命令描述
这个三个命令分别用于关闭(halt)、断电(poweroff)、重启(reboot)计算机。
这些命令都是指向systemctl的软链接。
命令支持的选项及含义
命令支持的选项如下:
–halt 无论调用三个命令中的哪一个,都停止(halt)计算机。
-p, –poweroff 无论调用三个命令中的哪一个,都关闭(poweroff)计算机。
–reboot 无论调用三个命令中的哪一个,都重启(reboot)计算机。
-f, –force 强行立即停止,关机,重启。不要联系init系统。
-w, –wtmp-only 只向wtmp中写入关机条目,但实际上不会停止,关机,重启。
-d, –no-wtmp 不要向wtmp中写入关机条目。
-n, –no-sync 在停止、关闭电源、重启之前,请勿同步硬盘/存储介质。
–no-wall 在停止、关机、重启之前,不要发送消息。
注意事项
这些旧版命令仅可用于兼容性。
关于halt和poweroff的不同
命令poweroff用于关闭计算机。它会终止所有进程,并关闭CPU,同时它也会关闭设备本身(灯光和PC上的所有东西)并向板上发送ACPI命令,然后向PSU发送,以切断电源。
命令halt也是用于关闭计算机。但是,它只会终止所有进程,并关闭cpu。
退出状态
0 成功
>0 失败
相关手册
systemd(1), systemctl(1), shutdown(8), wall(1)
参考文献

man 8 halt, Version 232-22
What’s the difference between poweroff and halt? [duplicate]

更新日志

08/10/2018 创建文章[……]

READ MORE

「hostnamectl(1)」-

控制系统主机名
命令语法格式
hostnamectl [OPTIONS…] {COMMAND}
命令描述
命令hostnamectl可用于查询和更改系统主机名和相关设置。
这个工具区分了三个不同的主机名:

高级“漂亮”主机名:可能包含各种特殊字符(例如“Lennart’s Laptop”);
静态主机名:用于在启动时初始化内核主机名(例如“lennarts-laptop”);
临时主机名,它是从网络配置接收到的回退值。如果设置了静态主机名并且该主机名有效(“localhost”之外的其他主机名),则不使用临时主机名。

请注意,漂亮的主机名对使用的字符和长度几乎没有限制,而静态和瞬态主机名仅限于网络域名通常接受的字符,最多64个字符(后者是Linux的限制)。
静态主机名存储在/etc/hostname中,有关详细信息,请参阅hostname(5)。漂亮的主机名、机器类型、图标名称存储在/etc/machine-info中,请参阅machine-info(5)手册。
对于已挂载(但未启动)的系统映像,使用systemd-firstboot(1)来初始化系统主机名。
命令支持的选项及含义
命令支持的选项如下:
–static, –transient, –pretty 如果COMMAND为“status”,或者没有给出明确的COMMAND,并且指定了其中一个选项,则命令hostnamectl将仅打印出对应的主机名。
如果COMMAND为“set-hostname”,则只更新选定的主机名。如果指定了多个这些选项,则将更新所有指定的主机名。
-H, –host= 在远程主机上执行操作。该选项指定要连接的主机名,或用“@”分隔的用户名和主机名。主机名可以后缀容器名,以“:”分隔,它直接连接到指定主机上的特定容器。这将使用SSH来与远程机器管理器实例通信。可以使用machinectl -H HOST枚举容器名称。
-M, –machine= 在本地容器上执行操作。指定要连接的容器名称。
–no-ask-password 对于特权操作,不要向用户查询身份验证。
-h, –help 显示帮助信息并退出。
–version 显示版本信息并退出。
支持的命令
本部分描述了在命令中COMMAND的可能取值:
status 显示当前系统主机名和相关信息。
set-hostname NAME 将系统主机名设置为NAME。
默认情况下,这将改变漂亮、静态、临时主机名;但是,如果使用–static、–transnsient、–pretty中的一个或多个,则只更改选[……]

READ MORE

「init(1)」-

systemd系统和服务的管理器
命令描述
参考systemd(1)手册。
参考文献

man 1 systemd, Version 239-7

更新日志

09/26/2018 创建文章[……]

READ MORE

「poweroff(8)」-

关闭计算机
命令描述
参考halt(8)手册。
参考文献

man 8 halt, Version 232-22

更新日志

08/10/2018 创建文章[……]

READ MORE

「reboot(8)」-

重启计算机
命令描述
参考halt(8)手册。
参考文献

man 8 halt, Version 232-22

更新日志

08/10/2018 创建文章[……]

READ MORE

「runlevel(8)」-

打印之前和当前的SysV运行级别
命令语法格式
runlevel [options…]
命令描述
概述
“运行级别”是启动和停止在SysV的init中使用的服务组的过时方式。systemd提供了一个兼容层,用于将”运行级别“映射到”目标“,以及相关的二进制文件,如runlevel。 然而,在给定时间只有一个运行级别可以“活动”,而systemd可以同时激活多个目标,因此映射到运行级别是令人困惑的并且只是近似的。 不应在新代码中使用运行级别,并且它们最常用作在内核引导参数中作为”引用匹配的systemd目标“的简便方法。
Table 1. Mapping between runlevels and systemd targets
┌─────────┬───────────────────┐
│Runlevel │ Target │
├─────────┼───────────────────┤
│0 │ poweroff.target │
├─────────┼───────────────────┤
│1 │ rescue.target │
├─────────┼───────────────────┤
│2, 3, 4 │ multi-user.target │
├─────────┼───────────────────┤
│5 │ graphical.target │
├─────────┼───────────────────┤
│6 │ reboot.target │
└─────────┴───────────────────┘

关于runlevel命令
如果已知,则runlevel打印上一个和当前的SysV运行级别。
两个运行级别字符由单个空格字符( )分隔。 如果无法确定运行级别,则会打印N。如果两者都无法确定,则打印“unknown”一词。
除非在环境中被覆盖,否则将检查utmp数据库以查找最近的运行级别更改。
命令支持的选项及含义
–help 打印简单的帮助信息,然后退出。
相关文件
/var/run/utmp utmp数据库,runlevel从中读取之前和当前的运行级别。
相关环境变量
RUNLEVEL 如果设置了$RUNLEVEL,则runlevel将此值作为”当前运行级别“打印,并忽略utmp。
PREVLEVEL 如果设置了$PREVLEVEL,则runlevel将此值作为”上一个运行级别“打印,并忽略utmp。
退出状态
0 能有确定一个或者两个运行级别。
>0 非零的失败码。
相关手[……]

READ MORE

「shutdown(8)」-

停止、关闭、重启主机
命令语法格式
shutdown [OPTIONS…] [TIME] [WALL…]
命令描述
命令shutdown可用于暂停、关闭电源、重启机器。
参数TIME是可选的,可以是时间字符串(通常是“now”)。时间字符串TIME可以采用“hh:mm”格式,表示”小时/分钟“,指定执行关闭时间,以24小时时钟格式指定。或者,它可以是语法“+m”,指的是从现在开始的指定分钟数后关机。“now”是“+0”的别名,即用于触发立即关闭。如果未指定时间参数TIME,则默认为“+1”。
如果使用了TIME参数,则在系统关闭前5分钟会创建/run/nologin文件以确保不允许进一步登录。
参数WALL是可选。表示在停止之前,向所有登录用户发送WALL消息。注意,要指定WALL消息,则必须指定时间TIME参数。
命令支持的选项及含义
命令支持的选项如下:
-H, –halt 停止机器。
-P, –poweroff 关闭机器电源(默认)。
-r, –reboot 重新启动机器。
-h 相当于–poweroff,除非指定了–halt选项。
-k 不要停止、关机、重新启动,只需写入留言信息WALL。
–no-wall 在停止、关机、重启之前,不要发送墙消息。
-c 取消挂起的关机。这可以用于取消参数TIME不为“+0”或“now”的shutdown的调用。
–help 显示帮助信息并退出。
退出状态
0 成功
>0 失败
相关手册
systemd(1), systemctl(1), halt(8), wall(1)
参考文献

man 8 shutdown, Version 232-22

更新日志

08/10/2018 创建文章[……]

READ MORE

「systemctl」-

功能简述
systemctl – Control the systemd system and service manager
常用命令
开机启动不在默认目录中的单元文件:

systemctl enable /path/to/my-service-file.serivce

语法格式

systemctl [OPTIONS…] COMMAND [NAME…]

命令描述
systemctl may be used to introspect and control the state of the “systemd” system and service manager. Please refer to systemd(1) for an introduction into the basic concepts and functionality this tool manages.
命令选项

The following options are understood:

-t, –type=

The argument should be a comma-separated list of unit types such as service and socket.

If one of the arguments is a unit type, when listing units, limit display to certain unit types. Otherwise, units of all types will be shown.

As a special case, if one of the arguments is help, a list of allowed values will be printed and the program will exit.

–state=

The argument should be a comma-separated list of unit LOAD, SUB, or ACTIVE states. When listing units, show only those in the specified states. Use –state=failed to show only failed units.

As a special case, if one of the arguments is hel[……]

READ MORE

「systemd-machine-id-setup」-

systemd-machine-id-setup – Initialize the machine ID in /etc/machine-id

命令语法格式

systemd-machine-id-setup

命令描述

systemd-machine-id-setup may be used by system installer tools to initialize the machine ID stored in /etc/machine-id at install time, with a provisioned or randomly generated ID. See machine-id(5) for more information about
this file.

If the tool is invoked without the –commit switch, /etc/machine-id is initialized with a valid, new machined ID if it is missing or empty. The new machine ID will be acquired in the following fashion:

1. If a valid D-Bus machine ID is already configured for the system, the D-Bus machine ID is copied and used to initialize the machine ID in /etc/machine-id.

2. If run inside a KVM virtual machine and a UUID is configured (via the -uuid option), this UUID is used to initialize the machine ID. The caller must ensure that the UUID passed is sufficiently unique and is different for

every booted instance of the VM.

3. Similarly, if run inside a Linux container environment and a UUID is configured for the container, this is used to i[……]

READ MORE

「systemd-tty-ask-password-agent」-

systemd-tty-ask-password-agent – List or process pending systemd password requests

命令语法格式

systemd-tty-ask-password-agent [OPTIONS…] [VARIABLE=VALUE…]

命令描述

systemd-tty-ask-password-agent is a password agent that handles password requests of the system, for example for hard disk encryption passwords or SSL certificate passwords that need to be queried at boot-time or during
runtime.

systemd-tty-ask-password-agent implements the Password Agents Specification[1].

命令支持的选项及含义

The following options are understood:

–list

Lists all currently pending system password requests.

–query

Process all currently pending system password requests by querying the user on the calling TTY.

–watch

Continuously process password requests.

–wall

Forward password requests to wall(1) instead of querying the user on the calling TTY.

–plymouth

Ask question with plymouth(8) instead of querying the user on the calling TTY.

–console

Ask question on /dev/console instead of quer[……]

READ MORE

「telinit(8)」-

修改SysV的运行级别
命令语法格式
telinit [OPTIONS…] {COMMAND}
命令描述
命令telinit可用于更改SysV系统运行级别。 由于SysV运行级别的概念已过时,运行级别请求将透明地转换为systemd单元激活请求。
命令支持的选项及含义
支持的选项([OPTIONS…])如下:
–help 显示简短的帮助信息,然后退出。
–no-wall 在重启/暂停/关机之前,不要发送墙消息。
支持的命令({COMMAND})如下:
0 关闭机器电源。 这被转换为poweroff.target的激活请求,相当于systemctl poweroff命令。
6 重新启动机器。 这被转换为reboot.target的激活请求,相当于systemctl reboot命令。
2, 3, 4, 5 更改SysV运行级别。 这被转换为runlevel2.target,runlevel3.target,…的激活请求,相当于systemctl isolate runlevel2.target,systemctl isolate runlevel3.target,…
1, s, S 进入系统救援模式。 这被转换为rescue.target的激活请求,相当于systemctl rescue命令。
q, Q 重新加载守护程序配置。 这相当于systemctl daemon-reload命令。
u, U 序列化状态,重新执行守护程序,并再次反序列化状态。 这相当于systemctl daemon-reexec命令。
注意事项
这是仅用于兼容性的旧命令。 它不应再被使用,因为运行级别的概念已经过时。
退出状态
0 成功
>0 失败
相关手册
systemd(1), systemctl(1), wall(1)
参考文献

man 8 telinit, Version 239-7

更新日志

09/27/2018 创建文章[……]

READ MORE

「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

「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