Linux 提供了丰富的帮助手册,通过 man 命令可以查看 Linux 中的命令帮助、配置文件帮助和编程帮助等信息。
存放路径:/usr/share/man
常用选项:
-a | 在所有的man帮助手册中搜索 |
---|---|
-d | 检查新加入的文件是否有错误 |
-f | 显示给定关键字的简短描述信息 |
-p | 指定内容时使用分页程序 |
-M | 指定man手册搜索的路径 |
-w | 显示文件所在位置 |
-k | 查找包含指定字符的命令描述信息 |
快捷键:
q | 退出 |
---|---|
Enter | 按行下翻 |
Space | 按页下翻 |
b | 上翻一页 |
/字符串 | 向前查找包含字符串的行 |
?字符串 | 向后查找包含字符串的行 |
n | 查找下一个 |
N | 查找上一个 |
p | 跳到文件最开始 |
G | 跳到文件最末尾 |
参考示例:
man -k process:查找包含process字符的命令文档描述信息
[root@rocky-01 linux]# man -k process
awk (1) - pattern scanning and processing language
bootup (7) - System bootup process
chrt (1) - manipulate the real-time attributes of a process
coredumpctl (1) - Retrieve and process saved core dumps and metadata
cpupower (1) - Shows and sets processor power related values
cpupower-info (1) - Shows processor power related kernel or hardware configurations
cpupower-monitor (1) - Report processor frequency and idle statistics
cpupower-set (1) - Set processor power related kernel or hardware configurations
dbus-run-session (1) - start a process as a new D-Bus session
dsa (1ssl) - DSA key processing
ec (1ssl) - EC key processing
查看指定命令的帮助信息:man ls
LS(1) User Commands LS(1)
NAME
ls - list directory contents
SYNOPSIS
ls [OPTION]... [FILE]...
DESCRIPTION
List information about the FILEs (the current directory by default). Sort entries alphabetically if
none of -cftuvSUX nor --sort is specified.
Mandatory arguments to long options are mandatory for short options too.
-a, --all
do not ignore entries starting with .
-A, --almost-all
do not list implied . and ..
--author
with -l, print the author of each file
-b, --escape
print C-style escapes for nongraphic characters
--block-size=SIZE
with -l, scale sizes by SIZE when printing them; e.g., '--block-size=M'; see SIZE format
below
标题 | 含义 |
---|---|
NAME | 命令名称及功能 |
SYNOPSIS | 命令语法,包括可用的选项 |
DESCRIPTION | 命令功能的详细说明 |
OPTIONS | 每个选项的详细说明 |
EXAMPLES | 用法示例 |
ENVIRONMENT | 命令使用的环境变量 |
FILES | 命令相关的配置文件 |
AUTHOR | 程序的作者 |
BUGS | 错误、缺点、警告 |
COPYRIGHT | 版权信息 |
SEE ALSO | 参照、相关信息 |
[ ] | 可选内容 |
< > | 必选内容 |
a | b | 二选一 |
{ } | 分组 |
...... | 同一个内容可出现多次 |
章节 | 说明 |
---|---|
1 | 标准用户命令(包含大量的命令手册) |
2 | 系统调用(在程序中使用,用来请求内核执行指令) |
3 | 库调用 |
4 | 特殊文件(包含物理设备和设备的驱动信息) |
5 | 文件格式(包含配置文件) |
6 | 游戏 |
7 | 杂项(各种混杂信息) |
8 | 管理命令(系统管理员使用的特殊命令) |
9 | 系统内核KPI |
查看指定配置文件的帮助信息
[root@rocky-01 linux]# man 5 passwd
PASSWD(5) Linux Programmer's Manual PASSWD(5)
NAME
passwd - password file
DESCRIPTION
The /etc/passwd file is a text file that describes user login accounts for the system. It should
have read permission allowed for all users (many utilities, like ls(1) use it to map user IDs to
usernames), but write access only for the superuser.
In the good old days there was no great problem with this general read permission. Everybody could
read the encrypted passwords, but the hardware was too slow to crack a well-chosen password, and
moreover the basic assumption used to be that of a friendly user-community. These days many people
run some version of the shadow password suite, where /etc/passwd has an 'x' character in the pass‐
word field, and the encrypted passwords are in /etc/shadow, which is readable by the superuser only.
passwd(1) to
..............省略...............................
找到某个命令的帮助信息和存储位置
[root@rocky-01 linux]# man -w ls
/usr/share/man/man1/ls.1.gz
找到某个配置文件的帮助信息的存储位置
[root@rocky-01 linux]# man -w 5 passwd
/usr/share/man/man5/passwd.5.gz