GNU/Linux 的核心在于变得更加自立。与此系统通常的情况一样,有几种方法可以实现这个目标。一个常见的获取帮助的方式是找到一个懂的人,然而,尽管 Linux 用户社区非常耐心和爱好和平,但几乎每个人都希望你在向他们求助之前已经尝试过本节中的一种或多种方法,如果你被证明没有遵循这个基本规则,他们表达这种观点的方式可能会相当严厉。
许多初学者害怕 man(manual,手册)页,因为它们是庞大的文档来源。然而,它们结构非常清晰,正如你将从下面关于 man man 的示例中看到的那样。
阅读 man 手册页通常在图形模式下的终端窗口中完成,或者如果你喜欢,也可以在文本模式下完成。在提示符下键入如下命令,然后按 Enter 键
yourname@yourcomp ~> man man |
按下 Enter 键后,关于 man 的文档将显示在你的屏幕上
man(1) man(1) NAME man - format and display the on-line manual pages manpath - determine user's search path for man pages SYNOPSIS man [-acdfFhkKtwW] [--path] [-m system] [-p string] [-C config_file] [-M pathlist] [-P pager] [-S section_list] [section] name ... DESCRIPTION man formats and displays the on-line manual pages. If you specify section, man only looks in that section of the manual. name is normally the name of the manual page, which is typically the name of a command, function, or file. However, if name contains a slash (/) then man interprets it as a file specification, so that you can do man ./foo.5 or even man /cd/foo/bar.1.gz. See below for a description of where man looks for the manual page files. OPTIONS -C config_file lines 1-27 |
使用空格键浏览到下一页。你可以使用 b 键返回上一页。当你到达末尾时,man 通常会退出,你会回到提示符。如果你想在到达末尾之前离开 man 手册页,或者如果查看器没有在页面末尾自动退出,请键入 q。
![]() | 分页器 |
---|---|
用于操作 man 手册页的可用组合键取决于你的发行版中使用的分页器。大多数发行版使用 less 来查看 man 手册页和滚动浏览。有关分页器的更多信息,请参见第 3.3.4.2 节。 |
每个 man 手册页通常包含几个标准部分,正如我们可以从 man man 示例中看到的那样
第一行包含你正在阅读的命令的名称,以及该 man 手册页所在的章节的 ID。man 手册页按章节排序。命令可能具有多个 man 手册页,例如来自用户章节的 man 手册页、来自系统管理员章节的 man 手册页以及来自程序员章节的 man 手册页。
给出了命令的名称和简短描述,用于构建 man 手册页的索引。你可以使用 apropos 命令在此索引中查找任何给定的搜索字符串。
命令的概要提供了此命令可以接受的所有选项和/或参数的技术表示法。你可以将选项视为执行命令的一种方式。参数是你对其执行操作的对象。某些命令没有选项或没有参数。可选的选项和参数放在 "[" 和 "]" 之间,以指示它们可以省略。
给出了命令的更长描述。
列出了选项及其描述。选项通常可以组合使用。如果不是这样,本节将告诉你。
环境描述了影响此命令行为的 shell 变量(并非所有命令都具有此项)。
有时会提供特定于此命令的部分。
在 "SEE ALSO" 部分中给出了对其他 man 手册页的引用。括号之间是要查找此命令的 man 手册页章节的编号。经验丰富的用户经常使用 / 命令后跟搜索字符串参见并按 Enter 键切换到 "SEE ALSO" 部分。
通常还有关于已知错误(异常)的信息,以及在哪里报告你可能发现的新错误。
可能还会有作者和版权信息。
某些命令具有多个 man 手册页。例如,passwd 命令在第 1 节中有一个 man 手册页,在第 5 节中还有另一个。默认情况下,显示编号最小的 man 手册页。如果你想查看默认章节以外的其他章节,请在 man 命令后指定它
man5 passwd
如果你想依次查看关于命令的所有 man 手册页,请使用-a到 man
man-a passwd
这样,当你到达第一个 man 手册页的末尾并再次按 SPACE 时,将显示来自下一节的 man 手册页。
除了 man 手册页之外,你还可以使用 info 命令阅读关于命令的 Info 页。这些通常包含更新的信息,并且使用起来稍微容易一些。某些命令的 man 手册页会引用 Info 页。
在终端窗口中键入 info info 开始
File: info.info, Node: Top, Next: Getting Started, Up: (dir) Info: An Introduction ********************* Info is a program, which you are using now, for reading documentation of computer programs. The GNU Project distributes most of its on-line manuals in the Info format, so you need a program called "Info reader" to read the manuals. One of such programs you are using now. If you are new to Info and want to learn how to use it, type the command `h' now. It brings you to a programmed instruction sequence. To learn advanced Info commands, type `n' twice. This brings you to `Info for Experts', skipping over the `Getting Started' chapter. * Menu: * Getting Started:: Getting started using an Info reader. * Advanced Info:: Advanced commands within Info. * Creating an Info File:: How to make your own Info file. --zz-Info: (info.info.gz)Top, 24 lines --Top------------------------------- Welcome to Info version 4.2. Type C-h for help, m for menu item. |
使用箭头键浏览文本,并将光标移动到以星号开头的行上,其中包含你想要了解信息的关键字,然后按 Enter 键。使用 P 键和 N 键转到上一个或下一个主题。空格键将使你前进一页,无论这是否开始一个新主题还是另一个命令的 Info 页。使用 Q 键退出。info 程序本身包含更多信息。
可以使用 whatis 命令获取命令解释的简短索引,如下例所示
[your_prompt] whatis ls ls (1) - list directory contents |
这会显示关于命令的简短信息,以及 man 手册页集合中包含相应页面的第一个章节。
如果你不知道从哪里开始以及要阅读哪个 man 手册页,apropos 会提供更多信息。假设你不知道如何启动浏览器,那么你可以输入以下命令
another prompt> apropos browser Galeon [galeon](1) - gecko-based GNOME web browser lynx (1) - a general purpose distributed information browser for the World Wide Web ncftp (1) - Browser program for the File Transfer Protocol opera (1) - a graphical web browser pilot (1) - simple file system browser in the style of the Pine Composer pinfo (1) - curses based lynx-style info browser pinfo [pman] (1) - curses based lynx-style info browser viewres (1x) - graphical class browser for Xt |
按下 Enter 键后,你将看到你的机器上有很多与浏览器相关的东西:不仅有 Web 浏览器,还有文件和 FTP 浏览器,以及文档浏览器。如果你安装了开发包,你可能还拥有随附的 man 手册页,用于处理编写与浏览器相关的程序。通常,在第一节中具有 man 手册页的命令,即标记为 "(1)" 的命令,适合用户尝试使用。因此,发出上述 apropos 命令的用户可能会尝试启动 galeon、lynx 或 opera 命令,因为这些命令显然与浏览万维网有关。
大多数 GNU 命令都支持--help选项,该选项提供关于如何使用命令以及可用选项列表的简短解释。以下是 cat 命令使用此选项的输出
userprompt@host: cat --help Usage: cat [OPTION] [FILE]... Concatenate FILE(s), or standard input, to standard output. -A, --show-all equivalent to -vET -b, --number-nonblank number nonblank output lines -e equivalent to -vE -E, --show-ends display $ at end of each line -n, --number number all output lines -s, --squeeze-blank never more than one single blank line -t equivalent to -vT -T, --show-tabs display TAB characters as ^I -u (ignored) -v, --show-nonprinting use ^ and M- notation, except for LFD and TAB --help display this help and exit --version output version information and exit With no FILE, or when FILE is -, read standard input. Report bugs to <bug-textutils@gnu.org>. |
如果你更喜欢图形用户界面,请不要失望。Konqueror,默认的 KDE 文件管理器,提供了轻松且色彩丰富的 man 和 Info 页面的访问方式。你可能想在位置地址栏中尝试 "info:info",你将获得关于 info 命令的可浏览 Info 页。类似地,"man:ls" 将向你展示 ls 命令的 man 手册页。你甚至可以获得命令名称补全:你将在下拉菜单中看到以 "ls" 开头的所有命令的 man 手册页。在地址位置工具栏中输入 "info:/dir" 会显示所有 Info 页,按实用程序类别排列。优秀的 内容,包括 Konqueror 手册。从菜单启动或在终端窗口中键入命令 konqueror,然后按 Enter;请参阅下面的屏幕截图。
Gnome 帮助浏览器也非常用户友好。你可以通过从 Gnome 菜单中选择 -> 、单击桌面上的救生员图标或在终端窗口中输入命令 gnome-help 来启动它。系统文档和 man 手册页可以通过简洁的界面轻松浏览。
nautilus 文件管理器提供了 man 和 Info 页面的可搜索索引,它们易于浏览且相互链接。Nautilus 可以从命令行启动,或者单击你的主目录图标,或者从 Gnome 菜单启动。
GUI 用于系统文档的最大优势在于所有信息都完全相互链接,因此你可以在 "SEE ALSO" 部分和任何出现其他 man 手册页链接的地方点击浏览,从而不间断地浏览和获取知识数小时。
某些命令没有单独的文档,因为它们是另一个命令的一部分。cd、exit、logout 和 pwd 就是这样的例外。它们是你的 shell 程序的一部分,被称为 shell 内置命令。有关这些命令的信息,请参阅你的 shell 的 man 或 info 页。大多数 Linux 初学者都使用 Bash shell。有关 shell 的更多信息,请参见第 3.2.3.2 节。
如果你已经更改了原始系统配置,则 man 手册页可能仍然存在,但由于你的 shell 环境已更改而不可见。在这种情况下,你需要检查MANPATH变量。如何在第 7.2.1.2 节中进行了解释。
某些程序或软件包仅在目录中有一组说明或参考/usr/share/doc。请参阅第 3.3.4 节以显示。
在最坏的情况下,你可能意外地从系统中删除了文档(希望是意外的,因为故意这样做是一个非常糟糕的主意)。在这种情况下,首先尝试使用搜索工具确保真的没有任何合适的东西留下,请继续阅读第 3.3.3 节。如果是这样,你可能需要重新安装包含文档所应用命令的软件包,请参见第 7.5 节。