Relative Content

LINUX MANUAL PAGES

category

「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

「setarch」-

在新的程序环境中修改报告的架构,以及设置个性标志
命令语法格式
setarch arch [options] [program [argument…]]
arch [options] [program [argument…]]
setarch –list|-h|-V
命令描述
setarch currently only affects the output of uname -m. For example, on an AMD64 system, running setarch i386 program will cause program to see i686 instead of x86_64 as the machine type. It also allows to set various personality options. The default program is /bin/sh.
命令支持的选项及含义

–list List the architectures that setarch knows about. Whether setarch can actually set each of these architectures depends on the running kernel.

–uname-2.6

Causes the program to see a kernel version number beginning with 2.6. Turns on UNAME26.

-v, –verbose

Be verbose.

-3, –3gb

Specifies program should use a maximum of 3GB of address space. Supported on x86. Turns on ADDR_LIMIT_3GB.

–4gb This option has no effect. It is retained for backward compatibility only, and may be removed in future releases.

-B, –32bit

Limit the address space to 32 bits to emulate hardware. Supported on ARM and Alpha. Turns on ADDR_LIMIT[……]

READ MORE

「setsid(1)」-

在新的会话中运行程序
命令语法格式
setsid [options] program [arguments]
命令描述
命令setsid在新会话中运行程序。如果已经是进程组所有者,则该命令调用fork(2)。否则,它在当前进程中执行程序。可以通过–fork选项覆盖此默认行为。
命令支持的选项及含义
-c, –ctty 将控制终端设置为当前终端。
-f, –fork 总是常见一个新的进程。
-w, –wait 等待程序的执行结束,并返回此程序的退出状态作为setsid的返回值。
-V, –version 显示版本信息并退出。
-h, –help 显示帮助信息并退出。
相关手册
setsid(2)
参考文献

man 1 setsid, Version setsid from util-linux 2.32

更新日志

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

READ MORE

「setterm」

setterm用于设置终端的属性。
SYNOPSIS
setterm [options]
DESCRIPTION
setterm writes to standard output a character string that will invoke the specified terminal capabilities. Where possible terminfo is consulted to find the string to use. Some options however (marked “virtual consoles only” below) do not correspond to a terminfo(5) capability. In this case, if the terminal type is “con” or “linux” the string that invokes the specified capabilities on the PC Minix virtual console driver is output. Options that are not implemented by the terminal are ignored.
OPTIONS
For boolean options (on or off), the default is on.
Below, an 8-color can be black, red, green, yellow, blue, magenta, cyan, or white.
A 16-color can be an 8-color, or grey, or bright followed by red, green, yellow, blue, magenta, cyan, or white.
The various color options may be set independently, at least on virtual consoles, though the results of setting multiple modes (for example, –underline and –half-bright) are hardware-dependent.
–appcursorkeys [on|off] (virtual consoles only) Sets Cursor Key Application Mode on or off. When on, ESC O A, ESC O B, etc. will be sent for the cursor keys inst[……]

READ MORE

「sfdisk」-

sfdisk – display or manipulate a disk partition table

命令语法格式

sfdisk [options] device [-N partition-number]

sfdisk [options] command

命令描述

sfdisk is a script-oriented tool for partitioning any block device.

Since version 2.26 sfdisk 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.

sfdisk (since version 2.26) aligns the start and end of partitions to block-device I/O limits when relative sizes are specified, when the default values are used or when multiplicative suffixes (e.g MiB) are used for sizes.
It is possible that partition size will be optimized (reduced or enlarged) due to alignment if the start offset is specified exactly in sectors and partition size relative or by multiplicative suffixes.

The recommended way is not to specify start offsets at all and specify partition size in MiB, GiB (or so). In this case sfdisk align all partitions to block-device I/O limits (or when I/O lim[……]

READ MORE

「sulogin(8)」-

单用户登录
命令语法格式
sulogin [options] [tty]
命令描述
当系统进入单用户模式时,程序init会调用sulogin。
用户会被提示:

Give root password for system maintenance
(or type Control-D for normal startup):

如果root帐户被锁定且指定了–force,则不需要密码。
命令sulogin将连接到当前终端,或连接到可在命令行上指定的可选tty设备(通常为/dev/console)。
当用户退出单用户Shell时,或者在提示符处按下Ctrl-D时,系统将继续引导。
命令支持的选项及含义
-e, –force 如果通过getpwnam(3)从系统获取root密码的默认方法失败,则检查/etc/passwd和/etc/shadow以获取密码。如果这些文件已损坏或不存在,或者root帐户被在密码开头的’*’或者“!”锁定,然后sulogin将启动root Shell而不需要密码。
如果您确定控制台在物理上受到保护,并且可以防止未经授权的访问,那么请仅使用-e选项。
-p, –login-shell 指定此选项会导致sulogin作为登录Shell启动shell进程。
-t, –timeout seconds 指定等待用户输入的最长时间。 默认情况下,sulogin会永远等待。
-h, –help 显示帮助信息并退出。
-V, –version 显示版本信息并退出。
相关环境变量
命令sulogin寻找环境变量SUSHELL或sushell来确定要启动的shell。 如果未设置环境变量,它将尝试从/etc/passwd执行root的shell。 如果失败,它将回退到/bin/sh。
参考文献

man 8 sulogin, Version sulogin from util-linux 2.32

更新日志

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

READ MORE

「swaplabel(8)」-

打印或者修改交换区域的标签或UUID
命令语法格式
swaplabel [-L label] [-U UUID] device
命令描述
命令swaplabel将显示或更改位于设备(或常规文件)上的交换分区的标签或UUID。
如果未给出可选参数-L和-U,则swaplabel将仅显示当前交换区域标签和设备的UUID。
如果存在可选参数,则swaplabel将更改设备上的相应值。 也可以在使用mkswap(8)创建交换期间设置这些值。 命令swaplabel允许更改一个激活使用的交换设备标签或UUID。
命令支持的选项及含义
-L, –label label 为设备指定新标签label。标签label最长可达16个字符。 如果label超过16个字符,swaplabel将截断它,并打印一条警告消息。
-U, –uuid UUID 为设备指定新的UUID。 UUID必须采用标准的8-4-4-4-12字符格式,例如由uuidgen(1)输出。
-h, –help 显示帮助信息并退出。
相关环境变量
LIBBLKID_DEBUG=all 启用libblkid的调试输出。
相关手册
uuidgen(1), mkswap(8), swapon(8)
参考文献

man 8 swaplabel, Version swaplabel from util-linux 2.32

更新日志

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

READ MORE

「swapoff(8)」-

禁用用于分页和交换的设备和文件
命令描述
命令swapoff禁用指定的设备和文件的交换。当给出-a标志时,禁用所有已知的交换设备和文件上的交换(如/proc/swaps或/etc/fstab中所示)。
详细的使用方法参考swapon(8)手册。
参考文献

man 8 swapon, Version swapon from util-linux 2.32

更新日志

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

READ MORE

「swapon(8)」-

启用/禁用用于分页和交换的设备和文件
命令语法格式
swapon [options] [specialfile…]
swapoff [-va] [specialfile…]
命令描述
命令swapon用于指定要进行分页和交换的设备。
由参数specialfile给出使用的设备或文件。它可以是-L label或-U uuid形式,来用于通过label或uuid来指示设备。
对swapon的调用通常发生在系统启动脚本中,使所有交换设备可用,因此分页和交换活动在多个设备和文件之间交错。
命令swapoff禁用指定的设备和文件的交换。当给出-a标志时,禁用所有已知的交换设备和文件上的交换(如/proc/swaps或/etc/fstab中所示)。
命令支持的选项及含义
启用交换分区
-a, –all 将所有在/etc/fstab中标记为“swap”设备设为可用,除了那些带有“noauto”选项的。 静默跳过已用作交换的设备。
-e, –ifexists 默默地跳过不存在的设备。 /etc/fstab挂载选项nofail也可用于跳过不存在的设备。
-L label 使用具有指定标签label的分区来作为交换分区。(为此,需要访问/proc/partitions。)
-U uuid 通过uuid指定要使用的分区。
-d, –discard[=policy] 如果交换后备设备支持丢弃或修整操作,则启用交换丢弃。 这可能会提高某些固态设备的性能,但通常不会。 该选项允许用户在两个可用的交换丢弃策略之间进行选择:

–dispard=once,在swapon时,对整个交换区域执行单次丢弃操作;
–discard=pages,在可以重用之前,异步丢弃释放的交换页面。

如果未选择任何策略,则默认行为是启用两种丢弃类型。 /etc/fstab挂载选项discard,discard=once,discard=pages也可用于启用discard标志。
-f, –fixpgsz 如果交换空间的页面大小与当前运行的内核的大小不匹配,则重新初始化(exec mkswap)。调用mkswap(2)初始化整个设备,不检查坏块。
-o, –options opts 通过fstab兼容的逗号分隔字符串指定交换选项。 例如:swapon -o pri=1,discard=pages,nofail /dev/sda2,评估最后的opts字符串,并覆盖所有其他命令行选项。
-p, –priority priority 指定交换设备的优先级。 priority是介于-1和32767之间的值。数字越大表示优先级越高。[……]

READ MORE

「switch_root(8)」-

切换到另一个文件系统作为挂载树的根目录
命令语法格式
switch_root [-hV]
switch_root newroot init [arg…]
命令描述
命令switch_root移动已经挂载/proc,/dev,/sys,/run文件系统到newroot下,并使newroot成为新的根文件系统,并启动init进程。
警告:命令switch_root会递归删除当前根文件系统上的所有文件和目录。
命令支持的选项及含义
-h, –help 显示帮助信息并退出。
-V, –version 显示版本信息并退出。
注意事项
如果newroot不是挂载的根目录,switch_root将无法运行。 如果要将root切换到不符合此要求的目录,则可以先使用“绑定挂载”技巧将任何目录转换为挂载点:mount –bind $DIR $DIR
退出状态
0 成功;
1 失败;
相关手册
chroot(2), init(8), mkinitrd(8), mount(8)
参考文献

man 8 switch_root, Version switch_root from util-linux 2.32

更新日志

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

READ MORE

「taskset(1)」-

设置或检索进程的CPU亲和性
命令语法格式
taskset [options] mask command [argument…]
taskset [options] -p [mask] pid
命令描述
命令taskset用于在给定pid的情况下设置或检索正在运行的进程的CPU亲和性,或者用于启动具有给定CPU亲和性的新命令。 CPU亲和性是一种调度程序属性,它将进程“绑定”到系统上的给定CPU集。 Linux调度程序将遵循给定的CPU亲和性,并且该进程不会在任何其他CPU上运行。请注意,Linux调度程序还支持自然CPU亲和性:由于性能原因,调度程序会尝试将进程保留在同一CPU上。因此,强制特定的CPU亲和性仅在某些应用程序中有用。
CPU亲和性表示为位掩码,最低位对应于第一逻辑CPU,最高位对应于最后一个逻辑CPU。并非所有CPU都可能存在于给定系统上,但掩码可能指定的CPU数量多于现有CPU数量。检索到的掩码将仅反映与系统上物理上的CPU相对应的位。如果给出了无效掩码(即,对应于当前系统上没有有效CPU的掩码),则返回错误。掩码可以用十六进制指定(带或不带前导“0x”),或带有–cpu-list选项的CPU列表。例如:

0x00000001,处理器#0,
0x00000003,处理器#0和#1,
0xFFFFFFFF,处理器#0~#31,
32,处理器#0、#4、#5,
–cpu-list 0-2,6,处理器#0、#1、#2、#6

当taskset返回时,保证给定的程序已被安排到合法的CPU。
命令支持的选项及含义
-a, –all-tasks 设置或检索给定PID的所有任务(线程)的CPU亲和性。
-c, –cpu-list 将mask解释为处理器的数字列表,而不是位掩码。 数字以逗号分隔,可能包括范围。 例如:0,5,8-11。
-p, –pid 在现有PID上运行,不要启动新任务。
-h, –help 显示帮助信息。
-V, –version 显示版本信息。
注意事项
权限
用户可以更改属于同一用户的进程的CPU亲和性。 用户必须拥有CAP_SYS_NICE才能更改属于另一个用户的进程的CPU亲和性。 用户可以检索任何进程的关联掩码。
使用示例
默认行为是使用给定的关联掩码运行新命令:

# taskset mask command [arguments]

您还可以检索现有任务的CPU亲和性:

# taskset -p pid

或者设置:

# taskse[……]

READ MORE

「terminal-colors.d」-

terminal-colors.d – Configure output colorization for various utilities
命令语法格式
/etc/terminal-colors.d/[[name][@term].][type]
命令描述

Files in this directory determine the default behavior for utilities when coloring output.

The name is a utility name. The name is optional and when none is specified then the file is used for all unspecified utilities.

The term is a terminal identifier (the TERM environment variable). The terminal identifier is optional and when none is specified then the file is used for all unspecified terminals.

The type is a file type. Supported file types are:

disable Turns off output colorization for all compatible utilities.

enable Turns on output colorization; any matching disable files are ignored.

scheme Specifies colors used for output. The file format may be specific to the utility, the default format is described below.

If there are more files that match for a utility, then the file with the more specific filename wins. For example, the filename “@xterm.scheme” has less priority than “dmesg@xterm.scheme”. The lowest priority are those fi[……]

READ MORE

「ul(1)」-

do underlining
命令语法格式
ul [-i] [-t terminal] [file …]
命令描述
命令ul读取命名文件(或标准输入,如果没有给出),并将下划线的出现转换为序列,该序列指示正在使用的终端的下划线,由环境变量TERM指定。 读取文件/etc/termcap以确定用于下划线的适当序列。
如果终端不能加下划线,但能够具有突出模式,则使用该终端。 如果终端可以重击,或自动处理下划线,则ul退化为cat(1)。 如果终端不能加下划线,则忽略下划线。
在翻译过程中,其他一些特殊字符也会被翻译。例如,TAB扩展到空间。
命令支持的选项及含义
-i 下划线由包含适当破折号“-”的单独行表示;当您想要查看CRT终端上的nroff(1)输出流中存在的下划线时,这非常有用。
-t terminal 使用terminal覆盖环境中指定的终端类型。
注意事项
命令nroff(1)通常输出一系列退格和下划线与文本混合以指示下划线。 没有尝试优化后向移动。
相关环境变量
LANG, LC_ALL, LC_CTYPE, TERM 这些环境变量会影响ul的执行。参考environ(7)手册。
退出状态
0 成功
>0 失败
使用示例
在终端中执行如下两个命令并观察输出:

# echo $’hello k\b_i\b_t\b_t\b_y\b_ world’ | ul
# echo $’hello k\b_i\b_t\b_t\b_y\b_ world’

第一个命令会以带有下划线的形式输出kitty单词。
相关手册
colcrt(1), man(1), nroff(1)
参考文献

man 1 ul, Version 9.0.12
How to use the ul command line utility

更新日志

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

READ MORE

「umount(8)」-

卸载文件系统
命令语法格式
umount -a [-dflnrv] [-t fstype] [-O option…]
umount [-dflnrv] {directory|device}…
umount -h | -V
命令描述
命令umount将提到的文件系统与文件层次结构分离。 通过给出已挂载目录的目录来指定文件系统。 给文件系统所在的特殊设备也可以使用,但是已经过时,主要是因为如果该设备挂载在多个目录上,它将会失败。
请注意,文件系统在“busy”时无法卸载 – 例如,当文件系统上有打开的文件,或者某个进程在其中有工作目录时,或者正在使用其中的交换文件时。 违规进程甚至可以自行卸载 – 它会打开libc,而libc可能会打开例如locale文件。 懒惰卸载(–lazy)可以避免这个问题。
命令支持的选项及含义
-a, –all 除了proc,devfs,devpts,sysfs,rpc_pipefs,nfsd文件系统之外,卸载/proc/self/mountinfo(或弃用的/ etc/mtab)中描述的所有文件系统。此文件系统列表可以替换为–types umount选项。
-A, –all-targets 卸载指定文件系统的当前命名空间中的所有挂载点。 文件系统可以由其中一个挂载点或设备名称(或UUID等)指定。 当此选项与–recursive一起使用时,文件系统中的所有嵌套挂载都将以递归方式卸载。
仅在/etc/mtab是/proc/mounts的符号链接的系统上支持此选项。
-c, –no-canonicalize 不要规范化路径。 路径规范化基于stat(2)和readlink(2)系统调用。 在某些情况下,这些系统调用可能会挂起(例如在NFS上如果服务器不可用)。 该选项必须与挂载点的规范路径一起使用。
有关此选项的更多详细信息,请参见mount(8)手册页。 请注意,umount不会将此选项传递给/sbin/umount.type帮助程序。
-d, –detach-loop 当卸载的设备是环路设备时,也可以释放此环路设备。 对于mount(8)初始化的设备,此选项是不必要的,在这种情况下,默认情况下启用“autoclear”功能。
–fake 除了实际的系统调用或umount帮助程序执行外,导致一切都要完成;这个’伪造’卸载文件系统。 它可用于从已弃用的/etc/mtab中删除条目(先前使用-n选项卸载的)。
-n, –no-mtab 无需在/etc/mtab中写入即可卸载。
-f, –force 强制卸载(如果无法访问NFS系统)。
请注意,此选项不保证umount命令不会挂起。[……]

READ MORE