「last(1)」-

显示上次登录用户列表
命令语法格式
last [options] [username…] [tty…]
lastb [options] [username…] [tty…]
命令描述
命令last搜索/var/log/wtmp文件(或-f选项指定的文件),并显示自该文件创建以来登录(和退出)的所有用户的列表。 可以给出一个或多个用户名或ttys,在这种情况下,last将仅显示与这些参数匹配的条目。参数ttys的名称可以缩写,因此last 0与last tty0相同。
当捕获SIGINT信号(由中断键产生,通常是control-C)或SIGQUIT信号时,last将显示它在文件中已经搜索的距离;在SIGINT信号的情况下,last将终止。
每次重启系统时,伪用户重启都会记录。 因此,last reboot将显示自创建日志文件以来所有重新启动的日志。
命令lastb与last相同,但默认情况下它显示/var/log/btmp文件的日志,其中包含所有错误的登录尝试。
命令支持的选项及含义
-f, –file file 告诉last使用特定文件而不是/var/log/wtmp。可以多次给出–file选项,会处理所有指定的文件。
-number, -n, –limit number 告诉last要显示多少行。
主机名
-a, –hostlast 在最后一列中显示主机名。 与–dns选项结合使用很有用。
-d, –dns 对于非本地登录,Linux不仅存储远程主机的主机名,还存储其IP地址。 此选项将IP地址转换回主机名。
-i, –ip 与–dns一样,但显示主机的IP号而不是名称。
-R, –nohostname 禁止显示主机名字段。
时间范围
-F, –fulltimes 打印完整登录和注销时间和日期。
-p, –present time 显示在指定时间出现的用户。这就像同时使用选项–since和–until一样。
-s, –since time 显示自指定时间以来的登录状态。 例如,这很容易确定谁在特定时间登录。 该选项通常与–until结合使用。
-t, –until time 显示登录状态,直到指定时间。
–time-format format 将输出时间戳格式定义为:notime,short,full,iso之一。notime变量根本不打印任何时间戳;short是默认值;full与–fulltimes选项相同;iso变量将以ISO-8601格式显示时间戳。ISO格式包含时区信息,因此在系统外部调查打印输出时更为可取。
其他信息
-w, –[……]

READ MORE

「lastb(1)」-

显示上次登录用户列表
命令描述
参考last(1)手册。
参考文献

man 1 lastb, Version 2.32.1-0.1

更新日志

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

READ MORE

「lsblk」

lsblk,以树形结构显示块设备的信息。

lsblk lists information about all available or the specified block devices. The lsblk
command reads the sysfs filesystem and udev db to gather information.

The command prints all block devices (except RAM disks) in a tree-like format by
default. Use lsblk –help to get a list of all available columns.

The default output, as well as the default output from options like –fs and –topol‐
ogy, is subject to change. So whenever possible, you should avoid using default out‐
puts in your scripts. Always explicitly define expected columns by using –output
columns-list in environments where a stable output is required.

Note that lsblk might be executed in time when udev does not have all information
about recently added or modified devices yet. In this case it is recommended to use
udevadm settle before lsblk to synchronize with udev.

命令行语法格式

lsblk [options] [device…]

命令行支持的选项及含义

-a, –all

Also list empty devices. (By default they are skipped.)

-b, –bytes

Print the SIZE column in bytes rather than in a human-re[……]

READ MORE

「lscpu」-

功能简述
lscpu – display information about the CPU architecture
常用命令
查看 CPU 信息

# lscpu
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
Address sizes: 39 bits physical, 48 bits virtual
CPU(s): 4
On-line CPU(s) list: 0-3
Thread(s) per core: 2
Core(s) per socket: 2
Socket(s): 1
NUMA node(s): 1
Vendor ID: GenuineIntel
CPU family: 6
Model: 60
Model name: Intel(R) Core(TM) i7-4600M CPU @ 2.90GHz
Stepping: 3
CPU MHz: 1370.629
CPU max MHz: 3600.0000
CPU min MHz: 800.0000
BogoMIPS: 5786.49
Virtualization: VT-x
L1d cache: 32K
L1i cache: 32K
L2 cache: 256K
L3 cache: 4096K
NUMA node0 CPU(s): 0-3
Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss
ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni
pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic[……]

READ MORE

「lslocks」-

NAME

lslocks – list local system locks

命令语法格式

lslocks [options]

命令描述

lslocks lists information about all the currently held file locks in a Linux system.

命令支持的选项及含义

-i, –noinaccessible

Ignore lock files which are inaccessible for the current user.

-J, –json

Use JSON output format.

-n, –noheadings

Do not print a header line.

-o, –output list

Specify which output columns to print. Use –help to get a list of all supported columns.

The default list of columns may be extended if list is specified in the format +list (e.g. lslocks -o +BLOCKER).

-p, –pid pid

Display only the locks held by the process with this pid.

-r, –raw

Use the raw output format.

-u, –notruncate

Do not truncate text in columns.

-V, –version

Display version information and exit.

-h, –help

Display help text and exit.

OUTPUT

COMMAND

The command name of the process holding the lock.

PID[……]

READ MORE

「lslogins」-

lslogins – display information about known users in the system

命令语法格式

lslogins [options] [-s|-u[=UID]] [-g groups] [-l logins]

命令描述

Examine the wtmp and btmp logs, /etc/shadow (if necessary) and /etc/passwd and output the desired data.

The default action is to list info about all the users in the system.

命令支持的选项及含义

Mandatory arguments to long options are mandatory for short options too.

-a, –acc-expiration

Display data about the date of last password change and the account expiration date (see shadow(5) for more info). (Requires root privileges.)

–btmp-file path

Alternate path for btmp.

-c, –colon-separate

Separate info about each user with a colon instead of a newline.

-e, –export

Output data in the format of NAME=VALUE.

-f, –failed

Display data about the users’ last failed login attempts.

-G, –supp-groups

Show information about supplementary groups.

-g, –groups=groups

Only show data of users belonging to groups. More than one group[……]

READ MORE

「mcookie(1)」-

为xauth生成cookie
命令语法格式
mcookie [options]
命令描述
命令mcookie生成一个128位随机十六进制数,用于X权限系统。 典型用法:

# xauth add :0 . `mcookie`

生成的“随机”数实际上是按优先顺序来自源getrandom()系统调用,/dev/urandom,/dev/random,libc伪随机函数之一的随机信息的MD5消息摘要。 另请参见–file选项。
命令支持的选项及含义
-f, –file file 使用此file作为附加的随机源(例如/dev/urandom)。 当file为’-‘时,从标准输入读取字符。
-m, –max-size number 仅从file中读取此字节数。从文件或设备读取其他随机性时,可以使用该选项。
参数number可以跟随乘法后缀: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等。
-v, –verbose 通知何处产生随机性,以及通过从每个源读取的熵量。
-V, –version 显示版本信息并退出。
-h, –help 显示帮助信息并退出。
注意事项
假设没有任何随机源会阻塞。
相关文件
/dev/urandom, /dev/random 随机数源。
相关手册
md5sum(1), X(1), xauth(1), rand(3)
参考文献

man 1 mcookie, Version mcookie from util-linux 2.32

更新日志

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

READ MORE

「mesg(1)」-

显示(或者屏蔽)来自其他用户的消息
命令语法格式
mesg [option] [n|y]
命令描述
命令mesg由用户来调用,用于控制其他人对与标准错误关联的终端设备的写入访问。如果用户允许写访问,则其他用户可以通过talk(1)和write(1)等程序在该用户的终端上显示消息。
传统上,默认情况下允许写访问。然而,随着用户意识到各种安全风险,默认情况下,至少在主登录Shell中删除写入访问。为了确保tty为期望的设置,应该在登录脚本中执行mesg命令。所以你在一些Linux发行版的登录脚本中会看到mesg n这样一条命令。
命令参数
n:不接收消息。
y:允许接收消息。
如果没有给出参数,则命令mesg在标准错误上输出消息状态,即是否允许显示消息。
命令支持的选项及含义
-v, –verbose 显示将要执什么动作。
-V, –version 显示版本信息。
-h, –help 显示帮助信息。
退出状态
命令mesg会以如下状态值退出:
0 允许消息。
1 不允许消息。
>1 发生了错误。
相关文件
/dev/[pt]ty[pq]? 相关的终端文件。
相关手册
login(1), talk(1), write(1), wall(1), xterm(1)
参考文献

man 1 mesg, version util-linux

更新日志

09/01/2017 创建文章
07/10/2018 修改文件内容,准备mplinux发布。[……]

READ MORE

「mkfs(8)」-

构建一个Linux文件系统
命令语法格式
mkfs [options] [-t type] [fs-options] device [size]
命令描述
不推荐使用此mkfs前端程序,而使用文件系统特定的mkfs.<type>系列工具。
命令mkfs用于在设备上构建Linux文件系统,通常是硬盘分区。参数device是设备名称(例如/dev/hda1,/dev/sdb2)或包含文件系统的常规文件。参数size是要用于文件系统的块数。
实际上,mkfs只是Linux下可用的各种文件系统构建器(mkfs.fstype)的前端。 仅通过PATH环境设置搜索特定于文件系统的构建器。 有关更多详细信息,请参阅特定于文件系统的构建器手册页。
命令支持的选项及含义
-t, –type type 指定要构建的文件系统的类型。 如果未指定,则使用默认文件系统类型(当前为ext2)。
fs-options 特定于文件系统的选项,用于传递给真实文件系统构建器。
-V, –verbose 生成详细输出,包括执行的所有特定于文件系统的命令。 多次指定此选项会禁止执行任何特定于文件系统的命令。 这实际上只对测试有用。
-V, –version 显示版本信息并退出。 (选项-V仅在它是唯一参数时显示版本信息,否则它将作为–verbose。)
-h, –help 显示帮助信息并退出。
注意事项
所有通用选项必须在文件系统特定选项fs-options之前,而不是与其结合。 某些特定于文件系统的程序不会自动检测设备大小,并且需要指定size参数。
退出状态
0 成功;
1 失败;
相关手册
fs(5), badblocks(8), fsck(8), mkdosfs(8), mke2fs(8), mkfs.bfs(8), mkfs.ext2(8), mkfs.ext3(8), mkfs.ext4(8), mkfs.minix(8), mkfs.msdos(8), mkfs.vfat(8), mkfs.xfs(8)
参考文献

man 8 mkfs, Version mkfs from util-linux 2.32

更新日志

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

READ MORE

「mkfs.bfs(8)」-

制作一个SCO bfs文件系统
命令语法格式
mkfs.bfs [options] device [block-count]
命令描述
命令mkfs.bfs在块设备上创建SCO bfs文件系统(通常是磁盘分区,或通过循环设备访问的文件)。
参数block-count是文件系统的所需大小(以块为单位)。 如果未指定任何内容,则将使用整个分区。
命令支持的选项及含义
-N, –inodes number 指定所需的inode数量(最多512个)。 如果未指定任何内容,则会根据分区的大小选择48-512范围内的某个默认编号。
-v, –verbose 详细模式,显示执行的操作。
-V, –vname label 指定卷名。我不知道是否/在哪里使用它。
-F, –fname name 指定文件系统名称。我不知道是否/在哪里使用它。
其他选项
-c 该选项被静默的忽略。
-l 该选项被静默的忽略。
-h, –help 显示帮助信息并退出。
-V, –version 显示版本信息并退出。选项-V仅在作为唯一选项的–version时起作用。
退出状态
0 成功;
1 发生错误;
相关手册
mkfs(8)
参考文献

man 8 mkfs.bfs, Verison mkfs.bfs from util-linux 2.32

更新日志

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

READ MORE

「mkfs.cramfs(8)」-

创建压缩的ROM文件系统
命令语法格式
mkfs.cramfs [options] directory file
命令描述
在cramfs文件系统上的文件一次被zlib压缩一页,以允许随机读取访问。 元数据不是压缩的,而是以简洁的表示形式进行表示,比传统的文件系统更节省空间。
文件系统是有意为只读的,以简化其设计;压缩文件的随机写访问很难实现。 cramfs附带一个实用程序(mkcramfs)来将文件打包到新的cramfs映像中。
文件大小限制为小于16MB。
最大文件系统大小略低于272MB。 (文件系统上的最后一个文件必须在256MB块之前开始,但可以延伸到它之后。)
命令行选项
-b blocksize 使用定义的块大小,必须可以按页面大小整除。
-e edition 在超级块中,使用定义的文件系统版本号。
-N big, little, host 使用定义的字节顺序。默认值为“host”。
-i file 将file插入cramfs文件系统。
-n name 设置cramfs文件系统的名称。
-p 为启动代码填充512字节。
-z 创建明确洞。
-E 将所有警告视为错误,将其反映为命令返回值。
-v 启用详细模式,打印更多的信息。
其他选项
-s 该选项已被忽略。原始的-s选项用于打开目录条目排序。
-h, –help 显示帮助信息。
-V, –version 显示版本信息。
命令行参数
该directory只是我们想要生成压缩文件系统的目录树的根目录。
该file将包含cram文件系统,以后可以安装。
退出状态
0 成功;
8 操作错误,比如无法分配内存;
相关手册
fsck.cramfs(8), mount(8)
参考文献

man 8 mkfs.cramfs, Version mkfs.cramfs from util-linux 2.32.1

更新日志

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

READ MORE

「mkfs.minix(8)」-

制作一个Minix文件系统
命令语法格式
mkfs.minix [options] device [size-in-blocks]
命令描述
参数mkfs.minix在设备(通常是磁盘分区)上创建Linux MINIX文件系统。
该device通常具有以下形式:

/dev/hda[1–8] (IDE disk 1)
/dev/hdb[1–8] (IDE disk 2)
/dev/sda[1–8] (SCSI disk 1)
/dev/sdb[1–8] (SCSI disk 2)

该device可以是块设备或一个映像文件,但这不是强制执行的。期待在字符设备上没有多少乐趣:-)。
参数size-in-blocks是文件系统的所需大小(以块为单位)。 它仅用于向后兼容。 如果省略,将自动确定大小。 只允许块计数严格大于10且严格小于65536。
命令支持的选项及含义
-c, –check 在创建文件系统之前,请检查设备是否存在坏块。 如果找到,则打印计数。
-n, –namelength length 指定文件名的最大长度。 目前,文件系统版本1和2的唯一允许值为14和30。版本3仅允许值60。默认值为30。
-i, –inodes number 指定文件系统的inode数。
-l, –badblocks filename 从filename中读取坏块列表。该文件每行有一个坏块编号。打印读取坏块的计数。
-1 制作一个Minix 版本1的文件系统。这是默认的。
-2, -v 制作一个Minix 版本2的文件系统。
-3 制作一个Minix 版本3的文件系统。
-h, –help 显示帮助信息。
-V, –version 显示版本信息。
退出状态
0 无错误;
8 操作错误;
16 用法或语法错误;
相关手册
fsck(8), mkfs(8), reboot(8)
参考文献

man 8 mkfs.minix, Version mkfs.minix from util-linux 2.32.1

更新日志

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

READ MORE

「mkswap(8)」-

设置Linux交换区域
命令语法格式
mkswap [options] device [size]
命令描述
命令mkswap在设备或文件中设置Linux交换区域。
参数device通常是磁盘分区(类似于/dev/sdb7),但也可以是文件。Linux内核不会查看分区ID(分区类型),但许多安装脚本会假设十六进制类型“82”(LINUX_SWAP)的分区是交换分区。 (警告:Solaris也使用此类型。请注意不要杀掉Solaris分区。)
参数size是多余的,但保留了向后兼容性。(它指定1024字节块中所需的交换区大小。如果省略,mkswap将使用整个分区或文件。指定它是不明智的 – 错字可能会破坏你的磁盘。)
创建交换区域后,需要使用swapon(8)命令开始使用它。 交换区域通常列在/etc/fstab中,以便在引导时通过某些引导脚本中的swapon -a命令使用它们。
命令支持的选项及含义
-c, –check 在创建交换区域之前,检查设备(如果是块设备)是否存在坏块。 如果找到任何坏块,则打印计数。
-f, –force 即使命令是愚蠢的,也要继续。 这允许创建大于它所驻留的文件或分区的交换区域。
此外,如果没有此选项,mkswap将拒绝擦除使用分区表的设备上的第一个块。
-L, –label label 为设备指定标签(LABEL),以允许在执行swapon(8)时使用标签(LABEL)。
不必要使用的选项
-p, –pagesize size 指定要使用的页面大小(以字节为单位)。 这个选项通常是不必要的,因为mkswap从内核中读取大小。
-U, –uuid UUID 指定要使用的UUID。 默认UUID是自动生成的。
-v, –swapversion 1 指定交换空间版本。 (这个选项目前没有意义,因为旧的-v 0选项已经过时,现在只支持-v 1。内核自2.5.22(2002年6月)起不支持-v 0交换空间格式。新版本-v 1是自内核2.1.117(1998年8月)起支持。
其他选项
-h, –help 显示帮助信息并退出。
-V, –version 显示版本信息并退出。
注意事项
交换区域的最大有用大小取决于体系结构和内核版本。
交换区域标头可以寻址的最大页数为4294967295(UINT_MAX)。交换设备上的剩余空间将被忽略。
目前,Linux允许32个交换区域。可以在/proc/swaps文件中看到正在使用的交换区域。
命令mkswap拒绝小于10页的交换区域。
如果您不知道机器使用的页面大小,您可以使用“cat /proc/cpuinfo”[……]

READ MORE

「more(1)」-

用于查看crt的文件读取过滤器
命令语法格式
more [options] file…
命令描述
命令more是一个过滤器,用于一次筛选一个屏幕文本,在终端上一次显示“一页”内容。或者说是一个“分页程序”。
命令支持的选项及含义
作用于命令的选项也取自环境变量MORE(确保在它们前面加上破折号(-)),但命令行指定的选项将覆盖这些选项。
-d 在窗口底部提示“[Press space to continue, ‘q’ to quit.]”,并显示“[Press ‘h’ for instructions.]”,而不是在按下非法键时响铃。
-l 在包含^L(换页,FF)的任何行之后不要暂停。
-f 计算逻辑行,而不是屏幕行(即,长行不进行折叠)。
-p 不要滚动。而是清除整个屏幕,然后显示文本。请注意,如果可执行文件名为“page”,则会自动打开此选项。
-c 不要滚动。而是从顶部绘制每个屏幕,清除每行显示的其余部分。
-s 将多个空白行合并成一个。
-u 抑制下划线。
-<number> 要使用的屏幕尺寸,以<number>数进行计算。例如more -5 filename。
+number 从指定的行号开始显示文件file的内容。例如man +5 filename,从第五行开始显示文件。
+/string 在开始显示之前,在每个文件中搜索的字符串。
其他选项
–help 显示帮助信息并退出。
-V, –version 显示版本信息并退出。
内置的交互命令
命令more的交互式命令基于vi(1)。某些命令前面可能有一个十进制数,在下面的描述中称为“k”,通常先按下数字,在按下命令。在以下描述中,“^X”表示“Ctrl-X”。
h, ? — 帮助;显示这些命令的摘要。如果忘记了所有其他命令,记住这一个就行。
q, Q, INTERRUPT — 退出。
= — 显示当前行号。
:f — 显示当前文件名和当前行号。
!command, :!command — 在子Shell中执行命令command。
v — 在当前行启动编辑器。 编辑器取自环境变量VISUAL(如果已定义),EDITOR(如果未定义VISUAL),如果未定义VISUAL和EDITOR,则默认为vi(1)。
^L 重新绘制屏幕。
. — 重复前一个命令。
多文件跳转
:n — 转到向后数“k”个的文件。 默认为1。
:p — 转到向前数“k”个的文件。 默认为1。
搜索相关
‘ — 转到上次搜索开始的位置。
/pattern[……]

READ MORE

「mount」

mount,挂载文件系统。
SYNOPSIS
mount [-l|-h|-V]
mount -a [-fFnrsvw] [-t fstype] [-O optlist]
mount [-fnrsvw] [-o options] device|dir
mount [-fnrsvw] [-t fstype] [-o options] device dir
DESCRIPTION
All files accessible in a Unix system are arranged in one big tree, the file hierarchy, rooted at /. These files can be spread out over several devices. The mount command serves to attach the filesystem found on some device to the big file tree. Conversely, the umount(8) command will detach it again.
The standard form of the mount command is:

mount -t type device dir

This tells the kernel to attach the filesystem found on device (which is of type type) at the directory dir. The previous contents (if any) and owner and mode of dir become invisible, and as long as this filesystem remains mounted, the pathname dir refers to the root of the filesystem on device.
If only the directory or the device is given, for example:

mount /dir

then mount looks for a mountpoint (and if not found then for a device) in the /etc/fstab file. It’s possible to use the –target or –source options to avoid ambivalent interpretation of the given argum[……]

READ MORE

「mountpoint(1)」-

检查文件或者目录是否为挂载点
命令语法格式
mountpoint [-d|-q] directory | file
mountpoint -x device
命令描述
命令mountpoint检查指定的文件或者目录是否存在于/proc/self/mountinfo文件中。
命令支持的选项及含义
-d, –fs-devno 打印挂载在给定目录上的主/次设备号。
-q, –quiet 默认会打印一条信息,该信息描述了文件或者目录是否为挂载点。使用该选项后,什么都不打印。
-x, –devno 在标准输出中打印给定块设备的主/次设备号。如果不是块设备,则会打印提示信息。
–help 显示帮助信息并退出。
–version 显示版本信息并退出。
退出状态
0 如果文件或者目录为挂载点
>0 非挂载点
相关环境变量
LIBMOUNT_DEBUG=all 启动libmount的调试选项。
注意事项
软件包util-linux中的mountpoint实现是从头开始为libmount编写的。而sysvinit套件的原始版本由Miquel van Smoorenburg编写。
相关手册
mount(8)
参考文献

man 1 mountpoint, version util-linux

更新日志

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

READ MORE

「namei(1)」-

跟随路径名,直到找到终点
命令语法格式
namei [options] pathname…
命令描述
命令namei将其参数解释为任何类型的Unix文件(符号链接、文件、目录等)的路径名。 然后,namei跟随每个路径名,直到找到一个端点(文件,目录,设备节点等)。如果找到符号链接,它会显示链接,并开始跟随它,缩进输出以显示上下文。
该程序对于找到“太多级别的符号链接”问题很有用。
对于每行输出,namei使用以下字符来标识找到的文件类型:

f:,当前正在解析的路径名
d,目录
l,符号链接(链接及其内容均输出)
s,套接字
b,块设备
c,字符设备
p,FIFO(命名管道)
-,常规文件
?,某种错误

当超出当前系统可能具有的最大符号链接数时,namei会打印消息。
命令支持的选项及含义
-l, –long 使用长列表格式(与-m -o -v相同)。
-m, –modes 以ls(1)的风格显示每种文件类型的模式位,例如’rwxr-xr-x’。
-n, –nosymlinks 不要跟随符号链接。
-o, –owners 显示每个文件的所属用户和所属组。
-v, –vertical 垂直对齐权限和所有者。
-x, –mountpoints 使用“D”来显示挂载点目录,而不是“d”。
其他选项
-h, –help 显示帮助信息。
-V, –version 显示版本信息。
相关手册
ls(1), stat(1), symlink(7)
参考文献

man 1 namei, Version namei from util-linux 2.32

更新日志

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

READ MORE

「nsenter」-

nsenter – run program with namespaces of other processes

命令语法格式

nsenter [options] [program [arguments]]

命令描述

Enters the namespaces of one or more other processes and then executes the specified program. If program is not given, then “${SHELL}” is run (default: /bin/sh).

Enterable namespaces are:

mount namespace

Mounting and unmounting filesystems will not affect the rest of the system, except for filesystems which are explicitly marked as shared (with mount –make-shared; see /proc/self/mountinfo for the shared flag). For
further details, see mount_namespaces(7) and the discussion of the CLONE_NEWNS flag in clone(2).

UTS namespace

Setting hostname or domainname will not affect the rest of the system. For further details, see namespaces(7) and the discussion of the CLONE_NEWUTS flag in clone(2).

IPC namespace

The process will have an independent namespace for POSIX message queues as well as System V message queues, semaphore sets and shared memory segments. For further details, see namespaces(7) and the discussion of the
CLONE_NEWIPC flag in clone([……]

READ MORE

「partx」-

partx – tell the kernel about the presence and numbering of on-disk partitions

命令语法格式

partx [-a|-d|-P|-r|-s|-u] [-t type] [-n M:N] [-] disk
partx [-a|-d|-P|-r|-s|-u] [-t type] partition [disk]

命令描述

Given a device or disk-image, partx tries to parse the partition table and list its contents. It can also tell the kernel to add or remove partitions from its bookkeeping.

The disk argument is optional when a partition argument is provided. To force scanning a partition as if it were a whole disk (for example to list nested subpartitions), use the argument “-” (hyphen-minus). For example:

partx –show – /dev/sda3

This will see sda3 as a whole-disk rather than as a partition.

partx is not an fdisk program – adding and removing partitions does not change the disk, it just tells the kernel about the presence and numbering of on-disk partitions.

命令支持的选项及含义

-a, –add

Add the specified partitions, or read the disk and add all partitions.

-b, –bytes

Print the SIZE column in bytes rather than in human-readable format.

-d, –d[……]

READ MORE

「pivot_root(8)」-

改变根文件系统
命令语法格式
pivot_root new_root put_old
命令描述
命令pivot_root将当前进程的根文件系统移动到put_old目录,并使new_root成为新的根文件系统。 由于pivot_root(8)只是调用pivot_root(2),因此我们将参考后者的手册页以获取更多详细信息。
请注意,根据pivot_root的实现,调用者的root和cwd可能会也可能不会更改。 以下是调用pivot_root的顺序,在任何一种情况下均可使用,假设pivot_root和chroot位于当前PATH中:

cd new_root
pivot_root . put_old
exec chroot . command

请注意,chroot必须在旧根目录下和新根目录下可用,因为pivot_root可能已经或可能没有隐式更改shell的根目录。
请注意,exec chroot会更改正在运行的可执行文件,如果之后应该卸载旧的根目录,这是必需的。 另请注意,标准输入、标准输出、标准错误仍可能指向旧根文件系统上的设备,使其保持忙碌状态。 调用chroot时可以轻松更改它们(请参阅下文;请注意,如果pivot_root已更改shell的根目录,则无需使用前导斜杠来使其工作)。
命令支持的选项及含义
-V, –version 显示版本信息并退出。
-h, –help 显示帮助信息并退出。
使用示例
从交互式shell将根文件系统更改为/dev/hda1:

mount /dev/hda1 /new-root
cd /new-root
pivot_root . old-root
exec chroot . sh <dev/console >dev/console 2>&1
umount /old-root

从10.0.0.1:/my_root通过NFS挂载新的根文件系统,并运行init:

ifconfig lo 127.0.0.1 up # for portmap
# configure Ethernet or such
portmap # for lockd (implicitly started by mount)
mount -o ro 10.0.0.1:/my_root /mnt
killall portmap # portmap keeps old root busy
cd /mnt
pivot_root . old_root
exec chr[……]

READ MORE

「prlimit」-

NAME

prlimit – get and set process resource limits

命令语法格式

prlimit [options] [–resource[=limits] [–pid PID]

prlimit [options] [–resource[=limits] command [argument…]

命令描述

Given a process ID and one or more resources, prlimit tries to retrieve and/or modify the limits.

When command is given, prlimit will run this command with the given arguments.

The limits parameter is composed of a soft and a hard value, separated by a colon (:), in order to modify the existing values. If no limits are given, prlimit will display the current values. If one of the values is not
given, then the existing one will be used. To specify the unlimited or infinity limit (RLIM_INFINITY), the -1 or ‘unlimited’ string can be passed.

Because of the nature of limits, the soft limit must be lower or equal to the high limit (also called the ceiling). To see all available resource limits, refer to the RESOURCE OPTIONS section.

soft:hard Specify both limits.

soft: Specify only the soft limit.

:hard Specify only the hard limit.

value Spe[……]

READ MORE

「raw(8)」-

绑定一个Linux原始字符设备
命令语法格式
raw /dev/raw/raw<N> <major> <minor>
raw /dev/raw/raw<N> /dev/<blockdev>
raw -q /dev/raw/raw<N>
raw -qa
命令描述
命令raw用于将Linux原始字符设备绑定到块设备。可以使用任何块设备:在绑定时,甚至不必访问设备驱动程序(它可以在以后作为内核模块按需加载)。
命令raw以两种模式使用:它设置原始设备绑定;或者查询现有绑定。
设置原始设备时,/dev/raw/raw<N>是文件系统中现有原始设备节点的设备名称。要绑定到的块设备可以根据其主设备号和次设备号指定,也可以指定为现有块设备文件的路径名/dev/<blockdev>。
可以使用-q选项查询已存在的绑定,该选项与原始设备文件名一起用于查询该设备,或使用-a选项查询所有绑定的原始设备。
可以通过指定major和minor 0来完成解绑。
一旦绑定到块设备,就可以打开、读取、写入原始设备,就像它绑定的块设备一样。但是,原始设备的行为与块设备不完全相同。特别是,对原始设备的访问完全绕过了内核的块缓冲区缓存:所有I/O都直接与执行I/O的进程的地址空间相连。如果底层块设备驱动程序可以支持DMA,则根本不需要数据复制来完成I/O.
由于原始I/O涉及对进程内存的直接硬件访问,因此必须遵守一些额外的限制。所有I/O必须在内存和磁盘上正确对齐:它们必须从磁盘上的扇区偏移开始;它们必须是精确的扇区数;并且虚拟内存中的数据缓冲区也必须与多个扇区对齐。对于大多数设备,扇区大小为512字节。
命令支持的选项及含义
-q, –query 设置查询模式。命令raw将查询现有绑定,而不是设置新绑定。
-a, –all 与-q一起使用,指定应查询所有绑定的原始设备。
-V, –version 显示版本信息并退出。
-h, –help 显示帮助信息并退出。
注意事项
Linux dd(1)命令应该在没有bs=选项的情况下使用,或者blocksize需要是设备扇区大小的倍数(通常为512字节),否则它将失败并显示“Invalid Argument”消息(EINVAL)。
原始I/O设备不与Linux块设备缓冲区高速缓存保持高速缓存一致性。如果使用原始I/O覆盖缓冲区高速缓存中已有的数据,则缓冲区高速缓存将不再对应于下面的实际存储设备的内容。 这是故意的,但根据您的要求,它被视为错误或功能!
与使用原始设备的应用程序相比,应该优先选择带[……]

READ MORE

「readprofile」-

readprofile – read kernel profiling information

命令语法格式

readprofile [options]

VERSION

This manpage documents version 2.0 of the program.

命令描述

The readprofile command uses the /proc/profile information to print ascii data on standard output. The output is organized in three columns: the first is the number of clock ticks, the second is the name of the C function
in the kernel where those many ticks occurred, and the third is the normalized `load’ of the procedure, calculated as a ratio between the number of ticks and the length of the procedure. The output is filled with blanks to
ease readability.

命令支持的选项及含义

-a, –all

Print all symbols in the mapfile. By default the procedures with reported ticks are not printed.

-b, –histbin

Print individual histogram-bin counts.

-i, –info

Info. This makes readprofile only print the profiling step used by the kernel. The profiling step is the resolution of the profiling buffer, and is chosen during kernel configuration (through `make config’), or in
the kernel’s command line. If the -t (terse) switch is us[……]

READ MORE

「rename(1)」-

重命名文件
命令语法格式
rename [options] expression replacement file…
命令描述
命令rename用于文件的重命名。该命令将文件参数file中匹配expression的部分替换成replacement。
参数[options]为命令行选项;expression是一个表达式,用于匹配文件名中要修改的部分;replacement是要替换成的内容;file…是要被重命名的多个文件。
而mv(1)实质上并不能算是个十分好用的重命名命令。
命令支持的选项及含义
-s, –symlink 不要重命名符号链接,而是重命名符号链接指向的文件。
-n, –no-act 不进行重命名操作。该选项可以配合-v选项来查看执行命令后将会进行哪些文件的重命名。
-o, –no-overwrite 不要覆盖已经存在的文件。
-v, –verbose 输出那些被重命名的文件。
-V, –version 显示版本信息并退出。
-h, –help 显示帮助信息并退出。
使用示例
(1) 对一群文件名为foo1, …, foo9, foo10, …, foo278的文件执行下面的两条命令:

# rename foo foo0 foo?
# rename foo foo0 foo??

会把这些文件重名为foo001, …, foo009, foo010, …, foo278。注意,命令里的问号(?)是由Shell解释的,foo?匹配foo1~foo9,命令rename foo foo0 foo?将这些文件重名为foo01~foo09。然后又执行了rename foo foo0 foo??命令,foo??匹配foo01~foo99,命令把它们重命名成foo001~foo099。正如你看到的,实际上并没有在foo100~foo278上执行操作。
(2) 命令:

# rename .htm .html *.htm

将以扩展名为.htm的文件的扩展名修改为.html。注意,命令里的星号(*)是由Shell进行解释的,匹配所有以.htm结尾的文件。
(3) 如果replacement为空,如下命令:

# rename ‘_with_long_name’ ” file_with_long_name.*

将去掉文件名中的_with_long_name部分。
注意事项
命令rename在某些Linux发行版里有两个:一个是Perl提供的,是一个Perl脚本;另一个是util-linux包提供的[……]

READ MORE

「renice(1)」-

alter priority of running processes
命令语法格式
renice [-n] priority [-g|-p|-u] identifier…
命令描述
命令renice改变一个或多个正在运行的进程的调度优先级。第一个参数是要使用的优先级值。 其他参数被解释为进程ID(默认情况下)、进程组ID、用户ID或用户名。如果是重新设置进程组,会导致进程组中的所有进程更改其调度优先级。如果是对用户进行重新设定,会导致用户拥有的所有进程都改变其调度优先级。
命令支持的选项及含义
-n, –priority priority 指定要用于进程,进程组或用户的调度优先级。 使用选项-n或–priority是可选的,但在使用时它必须是第一个参数。
-g, –pgrp 将命令参数identifier解释为进程组ID。
-p, –pid 将命令参数identifier解释为进程ID。默认行为。
-u, –user 将命令参数identifier解释为用户名或UID。
-V, –version 显示版本信息并退出。
-h, –help 显示帮助信息并退出。
注意事项
超级用户以外的用户只能改变他们拥有的进程的优先级。 此外,没有特权的用户只能增加“nice”值(即,选择较低的优先级),并且这种更改是不可逆的,除非(因为Linux 2.6.12)用户有一个合适的“nice”资源限制(参见 ulimit(1)和getrlimit(2))。
超级用户可以更改任何进程的优先级,并将优先级设置为-20到19范围内的任何值。有用的优先级是:19(受影响的进程只在系统中没有其他任何内容时才会运行),0(基本的调度优先级),任何负值(使事情变得非常快)。
使用示例
以下命令将更改具有PID 987和32的进程的优先级,以及用户daemon和root拥有的所有进程:

# renice +1 987 -u daemon root -p 32

如上示例。
相关文件
/etc/passwd 映射用户名与用户ID。
相关手册
nice(1), getpriority(2), setpriority(2), credentials(7), sched(7)
参考文献

man 1 renice, Version renice from util-linux 2.29.2

更新日志

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

READ MORE

「resizepart(8)」-

告诉内核一个分区的新大小
命令语法格式
resizepart device partition length
命令描述
命令resizepart告诉Linux内核有关指定分区的新大小。该命令是围绕ioctl的“resize partition”的简单包装。
此命令不会操作块设备上的分区。
命令参数
device 硬盘设备
partition 分区号。
length 分区的新长度(以512字节的扇区为单位)
相关手册
addpart(8), delpart(8), fdisk(8), parted(8), partprobe(8), partx(8)
参考文献

man 8 resizepart, Version resizepart from util-linux 2.32

更新日志

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

READ MORE

「rev(1)」-

反向输出行的字符
命令语法格式
rev [option] [file…]
命令描述
命令rev将指定的文件file复制到标准输出,并反转每行中的字符顺序。如果未指定文件file,则读取标准输入。
命令tac(1)是将文件中的行倒序输出;命令rev是将行里的字符倒序输出。
命令支持的选项及含义
-V, –version 显示版本信息并退出。
-h, –help 显示帮助信息并退出。
相关手册
tac(1)
参考文献

man 1 rev, Version rev from util-linux 2.32

更新日志

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

READ MORE

「rtcwake」-

rtcwake – enter a system sleep state until specified wakeup time

命令语法格式

rtcwake [options] [-d device] [-m standby_mode] {-s seconds|-t time_t}

命令描述

This program is used to enter a system sleep state and to automatically wake from it at a specified time.

This uses cross-platform Linux interfaces to enter a system sleep state, and leave it no later than a specified time. It uses any RTC framework driver that supports standard driver model wakeup flags.

This is normally used like the old apmsleep utility, to wake from a suspend state like ACPI S1 (standby) or S3 (suspend-to-RAM). Most platforms can implement those without analogues of BIOS, APM, or ACPI.

On some systems, this can also be used like nvram-wakeup, waking from states like ACPI S4 (suspend to disk). Not all systems have persistent media that are appropriate for such suspend modes.

Note that alarm functionality depends on hardware; not every RTC is able to setup an alarm up to 24 hours in the future.

The suspend setup maybe be interrupted by active hardware; for example wireless USB input devices that continue[……]

READ MORE

「script」-

make typescript of terminal session
命令语法格式

script [options] [file]

命令描述

script makes a typescript of everything displayed on your terminal. It is useful for students who need a hardcopy record of an interactive session as proof of an assignment, as the typescript file can be printed out later
with lpr(1).

If the argument file is given, script saves the dialogue in this file. If no filename is given, the dialogue is saved in the file typescript.

命令支持的选项及含义

-a, –append

Append the output to file or to typescript, retaining the prior contents.

-c, –command command

Run the command rather than an interactive shell. This makes it easy for a script to capture the output of a program that behaves differently when its stdout is not a tty.

-e, –return

Return the exit code of the child process. Uses the same format as bash termination on signal termination exit code is 128+n.

-f, –flush

Flush output after each write. This is nice for telecooperation: one person does `mkfifo foo; script -f foo’, and another can supervise real-time what is b[……]

READ MORE

「scriptreplay(1)」-

使用计时信息,重放“打字稿”文件
命令语法格式
scriptreplay [options] [-t] timingfile [typescript [divisor]]
命令描述
该程序使用定时信息来重放“打字稿”脚本,以确保输出以与记录脚本时最初出现的节奏相同的节奏发生。
重播只是再次显示信息;在“打字稿”记录时运行的程序不会再次运行。由于只显示相同的信息,因此只有在记录“打字稿”的相同类型的终端上运行时,scriptreplay才能保证正常工作。否则,在scriptreplay正在向其发送输出的终端上,该终端可以不同地解释“打字稿”中的任何转义字符。
如果使用-t参数运行,则定时信息为script(1)输出到标准错误的内容。
默认情况下,要显示的typescript假定为已被命名为typescript,但可以指定其他文件名(作为第二个参数,或使用-s选项)。
如果指定了第三个参数,则将其用作加速乘数。例如,加速“2”使得scriptreplay的速度提高了两倍,而加速“0.1”使其比原始会话慢十倍。
命令支持的选项及含义
前三个选项将覆盖旧式参数。
-t, –timing file 包含脚本定时输出的文件。
-s, –typescript file 包含脚本终端输出的文件。
-d, –divisor number 加快显示此number次数的重播速度。 参数是浮点数。 它被称为除数,因为它将时间除以这个因子。
-m, –maxdelay number 将抄本更新之间的最大延迟设置为number秒。 参数是浮点数。 这可用于避免抄本重播中的长时间暂停。
-V, –version 显示版本信息并退出。
-h, –help 显示帮助信息并退出。
使用示例
以下是一个简单的示例:

# script –timing=file.tm script.out
Script started, file is script.out
# ls
<etc, etc>
# exit
Script done, file is script.out
# scriptreplay –timing file.tm –typescript script.out

有关script和scriptreplay命令的用法示例,可以参考「How to Record and Replay Linux Terminal Sessions using ‘script’ and ‘scriptreplay’ Commands」一文
相关手册
scrip[……]

READ MORE