Linux 自带帮助查询
帮助命令
某些命令可以使用 --help
参数来查看简短的帮助信息。例如,要查看命令 mkdir
的帮助信息:
[user1@101c7 root]$ mkdir --help Usage: mkdir [OPTION]... DIRECTORY... Create the DIRECTORY(ies), if they do not already exist. Mandatory arguments to long options are mandatory for short options too. -m, --mode=MODE set file mode (as in chmod), not a=rwx - umask -p, --parents no error if existing, make parent directories as needed -v, --verbose print a message for each created directory -Z set SELinux security context of each created directory to the default type --context[=CTX] like -Z, or if CTX is specified then set the SELinux or SMACK security context to CTX --help display this help and exit --version output version information and exit GNU coreutils online help: <http://www.gnu.org/software/coreutils/> For complete documentation, run: info coreutils 'mkdir invocation
一些特殊符号的含义:
- 省略号
...
:表示可以有多个选项或参数。 - 中括号
[]
:之间的任何内容都是可选的。 - 大括号
{}
:表示应该选择由 | 隔开的各项中一个。 - 尖括号
<>
:内为变量表示参数可变。 - 不带中括号
[]
:表示必选项,必须作为命令的一部分输入。
查询手册
使用 man
命令可以查询操作手册(manual),所有内建命令都有对应的操作手册页面。
手册存放在 /usr/share/man
目录中,可以通过修改 /etc/man_db.conf
文件来定义 man 查询手册的位置。
例如使用 man
命令查询 mkdir
命令的手册:
[user1@101c7 root]$ man mkdir MKDIR(1) User Commands MKDIR(1) NAME mkdir - make directories SYNOPSIS mkdir [OPTION]... DIRECTORY... DESCRIPTION Create the DIRECTORY(ies), if they do not already exist. Mandatory arguments to long options are mandatory for short options too. -m, --mode=MODE set file mode (as in chmod), not a=rwx - umask -p, --parents no error if existing, make parent directories as needed -v, --verbose print a message for each created directory Manual page mkdir(1) line 1 (press h for help or q to quit)
在 man 页面使用方向键浏览,用空格或 [PageUp],[PageDown] 翻页。
输入 / 关键字来向下(? 关键字向上)搜索手册中的内容,在搜索中按 n 和 N 进行正向查询和反向查询。
使用 -f
选项查询命令相关说明文件:
[user1@101c7 root]$ man -f date date (1) - print or set the system date and time
通常查询显示的是最低编号的内容(可以在 man_db.conf 中设置)。可以使用数字指定查询相应区块文档:
[user1@101c7 root]$ man -f info info (1) - read Info documents info (5) - readable online documentation [user1@101c7 root]$ man 5 info INFO(5) File Formats Manual INFO(5) NAME info - readable online documentation
可以使用 -k
选项进行模糊查询:
[user1@101c7 root]$ man -k setse setsebool (8) - set SELinux boolean value [user1@101c7 root]$ man -k sets cpupower (1) - Shows and sets processor power related values ExtUtils::XSSymSet (3pm) - keep sets of symbol names palatable to the VMS linker ipset (8) - administration tool for IP sets setsebool (8) - set SELinux boolean value setsid (1) - run a program in a new session systemd.preset (5) - Service enablement presets
man 手册约定:
区域号 | 所涵盖的内容 |
---|---|
1 | 可执行程序或 shell 命令。 |
2 | 系统内核可调用的函数和工具等。 |
3 | 一些常用函数(Function)与函数库(Library),大部分为 C 的函数库(libc)。 |
4 | 设备文件的说明,通常在 /dev 下的文件。 |
5 | 配置文件或者是某些文件的格式。 |
6 | 游戏和演示。 |
7 | 惯例与协议等,例如文件系统、网络协议等名词解释。 |
8 | 只有超级用户和系统管理员可使用的系统管理命令。 |
9 | 内核例程,与 Kernel 有关的文件。 |
查询 Info 文档
类似于在命令行中浏览网页,使用 info
可以查询存放在 /usr/share/info/
目录下的文档。例如,可以使用以下命令查询有关 mkdir
的信息:
[user1@101c7 root]$ info mkdir File: libc.info, Node: Creating Directories, Next: File Attributes, Prev: Renaming Files, Up: File Sys\ tem Interface 14.8 Creating Directories ========================= Directories are created with the 'mkdir' function. (There is also a shell command 'mkdir' which does the same thing.)
其中,File 表示 info 页面的数据来源文件,Node 表示页面所属节点。在.info 的说明文件中,每个节点都有定位与链接,类似于超链接,可以快速跳转。