man和info是独立的命令, --help是个命令的参数, 它们都是Linux中获取帮助信息最权威,最快捷的途径。
1 help
想查看某个命令的用法时,比如查看ls命令的用法,可以执行:
ls --help
help只能用于查看某个命令的用法。
2 man
man手册既可以查看命令的用法,还可以查看函数的详细介绍等等。它含有9大分类,如下:
section | 名称 | 说明 |
---|---|---|
1 | Executable programs or shell commands:可执行程序或shell命令 | 用户可操作的命令 |
2 | System calls (functions provided by the kernel) :系统调用 | 内核提供的函数(查头文件) |
3 | Library calls (functions within program libraries):库调用 | 常用的函数库 |
4 | Special files (usually found in /dev):特殊文件 | 在/dev下的设备文件 |
5 | File formats and conventions eg /etc/passwd :文件格式和约定 | 对一些文件进行解释,如/etc/passpd |
6 | Games:游戏程序 | 游戏程序 |
7 | Miscellaneous (including macro packages and conventions), e.g. man(7), groff(7) :杂项 | 包括宏包和约定等 |
8 | System administration commands (usually only for root):系统管理员使用的管理命令 | 通常只有系统管理员root可以使用 |
9 | Kernel routines [Non standard] :内核相关 | Linux内核相关文件 |
比如想查看open函数的用法时,可以直接执行“man open”,发现这不是想要内容时再执行“man 2 open”。
在man命令中可以及时按“h”查看帮助信息了解快捷键。常用的快捷键是:
- f 往前翻一页
- b 往后翻一页
- /patten 往前搜
- ?patten 往后搜
3 info
就内容来说,info手册比man手册编写得要更全面,但man手册使用起来更容易些。
以书来形容info手册和man手册的话,info手册相当于一章,里面含有若干节,阅读时你需要掌握如果从这一节跳到下一节;而man手册只相当于一节,阅读起来当然更容易。可以直接执行“info”命令后,输入“H”查看它的快捷键,在info手册中,某一节被称为“node”。
常用的快捷键如下:
-
Up Move up one line.
-
Down Move down one line.
-
PgUp Scroll backward one screenful.
-
PgDn Scroll forward one screenful.
-
Home Go to the beginning of this node.
-
End Go to the end of this node.
-
TAB Skip to the next hypertext link.
-
RET Follow the hypertext link under the cursor.
-
l Go back to the last node seen in this window.
-
[ Go to the previous node in the document.
-
] Go to the next node in the document.
-
p Go to the previous node on this level.
-
n Go to the next node on this level.
-
u Go up one level.
-
t Go to the top node of this document.
-
d Go to the main ‘directory’ node.
参考资料: