个人工具

“UbuntuHelp:Man/zh”的版本间的差异

来自Ubuntu中文

跳转至: 导航, 搜索
介绍
介绍
 
(未显示4个用户的28个中间版本)
第1行: 第1行:
=== Introduction<br> ===
+
{{Copyedit translation|from=https://wiki.ubuntu.org.cn/UbuntuHelp:Man}} {{From|https://wiki.ubuntu.org.cn/UbuntuHelp:Man}} {{Translator|杨竞毅}} {{Verifier|杨竞毅}}{{Languages|UbuntuHelp:Man}}
  
The command-line program man is used for displaying Unix and Linux manual pages (usually called manpages). Manpages are self-contained reference documents stored on the machine's hard drive. They are usually short, but can be quite long. Ubuntu's manpage system has a reference for every command-line program, and in many cases it is the only source of information. Man displays the data using a pager, a type of program that shows files on text-based terminals one screen at a time. On Ubuntu, less is the pager that is used. The manpage system has been a part of Unix and Unix-like systems since the early 1980s, and although it is primitive by today's standards, it is nevertheless a useful resource. It offers a quick reference to the switches and and options available in terminal-based commands and programs such as ls, find, less, and of course, man itself. In addition, it also contains information on almost all of the GUI based programs on your system, such as gimp and firefox. This page describes how to use man at the command line, and gives an overview of the manpage system. It does not cover the tools apropos or whatis, both of which are used for searching parts of the manpage data, and both of which have equivalents in man using the -k and -f switches. The -k and -f switches are covered here.<br>
+
=== 介绍 ===
  
 +
命令行程序''man''是用来显示Unix和Linux用户手册页面的。这些用户手册页面是储存在计算机硬盘上的完备的参考文献。它们通常很短小,但也可能很长。Ubuntu的用户手册系统为每个命令行程序都提供了参考手册,而且很多时候这也是该命令行程序的唯一参考资料的来源。Man使用''分页程序''来显示数据,分页程序是一种以文本终端来一屏一屏地显示文件的程序。在Ubuntu上,''less''就是所用到的分页程序。自从20世纪80年代,用户手册页面系统就是Unix和类Unix系统的一部分,虽然在今天的标准看来,它很原始,但它仍然是一个有用的资源。它为基于终端的命令行和程序(比如''ls''、''find''、''less'',当然也包括''man''自身)提供了关于其可用的开关项和可选项的一种快速检索。另外,它还包含了你系统中绝大多数基于图形用户界面的程序的信息,如''gimp''和''firefox''。本页面描述了如何在命令行下使用man,并给出了用户手册系统的概述。本文内容不包含''apropos''和''whatis''命令,这两个命令都可用于搜索用户手册数据中的特定部分内容,而且它们都等效于使用了-k和-f开关项的man命令。但本页面覆盖了man命令的-k和-f开关项的内容。 <br>
  
 +
=== 使用Man命令 ===
  
=== 介绍 ===
+
当你知道你想要查询的命令名或程序名时,你可以输入<code><nowiki>man <命令名></nowiki></code>,像下面的例子所示的那样,这个例子向你展示了如何查看''less''命令的用户手册页面,用户手册系统正是用这个工具(less)来显示数据的。
 +
 
 +
{| cellspacing="0" border="1"
 +
|-
 +
|
 +
|-
 +
| jeffsch@mandela:~ '''man less'''
 +
|-
 +
| Reformatting less(1), please wait...
 +
|}
 +
 
 +
当用户手册页面打开后,使用上下箭头键和前后翻页键来浏览整个文件。按Q键来退出用户手册页面,返回到命令行状态。在文件中你可以用less的“/”命令来向前搜索,也可以用"?"命令来向後搜索。关于使用less的更多信息见它的用户手册页面。在上面的例子中,当用户手册页面正在後台被转化为一种适合于显示的格式时终端中会简要地显示一条消息“Reformatting less(1), please wait...”(正在转化less(1)的格式,请稍等...)。用户手册页面被分为9个主要的类别,被编号为1到9。上例的消息中的“(1)”部分指出所显示的用户手册页面属于第1类。 在本页面的最後给出了对不同用户手册页面分类的简要的说明。一个用户手册页面可能同时存在于两个或两个以上的分类中。例如man自身就有两个页面;一个在第1类中而另一个在第7类中。当你输入<code><nowiki>man man</nowiki></code>时,第1类中的页面会被显示。如果你想要查看第7类中的页面,则应输入<code><nowiki>man 7 man</nowiki></code>,正如下面的例子中所示范的一样。
 +
 
 +
{| cellspacing="0" border="1"
 +
|-
 +
|
 +
|-
 +
| jeffsch@mandela:~ '''man man'''
 +
|-
 +
| Reformatting man(1), please wait...
 +
|}
 +
 
 +
{| cellspacing="0" border="1"
 +
|-
 +
|
 +
|-
 +
| jeffsch@mandela:~ '''man 7 man'''
 +
|-
 +
| Reformatting man(7), please wait...
 +
|}
 +
 
 +
=== 查找用户手册页面 ===
  
 +
使用man命令的-k和-f开关项来查找用户手册页面。你也可以使用独立地等效于''man -k''和''man -f''命令的''apropos''和''whatis''命令。检索机制在你系统中的每个用户手册页面中查找,且每个页面只查找特定的一行。它所查找的那一行就在用户手册页面的NAME(名称)部分。用户手册页面被分为了几个部分,第1部分就是NAME(名称)部分。该部分包含了这个用户手册页面的名称和对该页面的主题所涉及到的内容的一个简短的描述。如果你的检索词没有出现在任何一个用户手册页面的NAME(名称)部分中,你的检索将返回零个结果。表1显示了一个典型的用户手册页面的前几行的一个实例,其中包括了NAME(名称)和SYNOPSIS(概要)部分以及DESCRIPTION(描述)部分的开头。
  
命令行程序man是用来显示Unix和Linux手册页面的。这些手册页面是储存在计算机硬盘上的完备的参考文献。它们通常很短小,但也可能很长。Ubuntu的手册页面系统为每个命令行程序都提供了参考手册,而且很多时候这也是该命令行程序的唯一参考资料的来源。Man使用分页程序来显示数据,&nbsp;分页程序是一种以文本终端来一屏一屏地显示文件的程序。
+
{| cellspacing="0" border="1"
 +
|-
 +
|
 +
|-
 +
| '''表1:'''<code><nowiki>ls</nowiki></code>命令的开头部分.
 +
|-
 +
| <code><nowiki>LS(1) LS(1)</nowiki></code>
 +
|-
 +
| '''NAME'''
 +
|-
 +
|
 +
|-
 +
| <code><nowiki>ls - list directory contents</nowiki></code>
 +
|-
 +
|
 +
|-
 +
| '''SYNOPSIS'''
 +
|-
 +
|
 +
|-
 +
| <code><nowiki>ls [OPTION]... [FILE]...</nowiki></code>
 +
|-
 +
|
 +
|-
 +
| '''DESCRIPTION'''
 +
|-
 +
|
 +
|-
 +
| (''此页面的剩余部分省略.'')
 +
|-
 +
|
 +
|}
 +
==== man -k ====
 +
当你用man命令的-k开关项来搜索用户手册页面时,每个用户手册页面的整个NAME(名称)部分都会被搜索而且搜索结果(如果有的话)会被显示。例如,如果你输入<code><nowiki>man -k find</nowiki></code>,你会得到类似于下表的一张明细表:
 +
{|border="1" cellspacing="0"
 +
|
 +
|-
 +
|jeffsch@mandela:~$ '''man -k find'''
 +
|-
 +
|<code><nowiki>bogotune (1)        - find optimum parameter settings for bogofilter</nowiki></code>
 +
|-
 +
|<code><nowiki>chkdupexe (1)        - find duplicate executables</nowiki></code>
 +
|-
 +
|<code><nowiki>FcConfigFilename (3) - Find a config file</nowiki></code>
 +
|-
 +
|<code><nowiki>find (1)            - search for files in a directory hierarchy</nowiki></code>
 +
|-
 +
|<code><nowiki>find2perl (1)        - translate find command lines to Perl code</nowiki></code>
 +
|-
 +
|<code><nowiki>findfs (8)          - Find a filesystem by label or UUID</nowiki></code>
 +
|-
 +
|<code><nowiki>gst-typefind-0.10 (1) - print MIME type of file</nowiki></code>
 +
|-
 +
|<code><nowiki>gst-typefind-0.8 (1) - print MIME type of file</nowiki></code>
 +
|-
 +
|<code><nowiki>mysql_find_rows (1)  - MySQL shell skript for searching in update logs.</nowiki></code>
 +
|-
 +
|<code><nowiki>pidof (8)            - find the process ID of a running program.</nowiki></code>
 +
|-
 +
|<code><nowiki>runlevel (8)        - find the previous and current system runlevel.</nowiki></code>
 +
|-
 +
|<code><nowiki>sane-find-scanner (1) - find SCSI and USB scanners and their device files</nowiki></code>
 +
|-
 +
|<code><nowiki>XFindContext (3)    - associative look-up routines</nowiki></code>
 +
|-
 +
|<code><nowiki>XtFindFile (3)      - search for a file using substitutions in the path list</nowiki></code>
 +
|-
 +
|<code><nowiki>jeffsch@mandela:~$</nowiki></code>
 +
|}
 +
请记住,只有每个用户手册页面的NAME(名称)部分会被搜索;如果你的检索词不在任何一个用户手册页面的NAME(名称)部分中,你的搜索就会返回零个结果。
 +
==== man -f ====
 +
当你用man命令的-k开关项来搜索时,只有用户手册页面的名字会被搜索。例如,如果你输入<code><nowiki>man -f find</nowiki></code>,你将得到如下所示的结果:
 +
{|border="1" cellspacing="0"
 +
|
 +
|-
 +
|jeffsch@mandela:~$ '''man -f find'''
 +
|-
 +
|<code><nowiki>find (1)            - search for files in a directory hierarchy</nowiki></code>
 +
|-
 +
|<code><nowiki>jeffsch@mandela:~$</nowiki></code>
 +
|}
 +
=== 用户手册页面的类别 ===
 +
用户手册页面被分为了9类,被编号为1到9。表2描述了这些分类。
 +
{|border="1" cellspacing="0"
 +
|
 +
|-
 +
|'''表 2:''' 用户手册页面分类.
 +
|-
 +
|1 - 可执行程序或shell命令
 +
|-
 +
|2 - 系统调用 (由内核提供的函数)
 +
|-
 +
|3 - 库调用 (程序库里的函数)
 +
|-
 +
|4 - 特殊文件 (常指在 /dev路径下找到的文件)
 +
|-
 +
|5 - 文件格式和协议 例如 /etc/passwd
 +
|-
 +
|6 - 游戏
 +
|-
 +
|<code><nowiki>7 - 杂类文件 (包括宏软件包和协议), 例如 man(7), groff(7)</nowiki></code>
 +
|-
 +
|8 - 系统管理命令 (通常只有超级用户才能使用)
 +
|-
 +
|9 - 内核程序 [非标准]
 +
|-
 +
|''资料来源: man(1)用户手册页面.''
 +
|}
 +
除了这些加了编号的分类之外,还有三个已经不再使用的分类,即字母''n'', ''o'', 和 ''l''。在新的用户手册系统中,我们已经不再使用这些分类了,但是你可能会在已经存在的文档和man命令的路径设置文件(<code><nowiki>/etc/manpath.config</nowiki></code>)中一次次地遇见它们。通过使用“扩展”,用户手册页面还可被细分为更小的类别。开发者和用户手册的作者比较关注这些小类别,而你则很有可能永远不用去管它,但你可以在man命令的用户手册页面中查找更多的相关信息。
 +
=== 资源 ===
 +
*在线浏览和查找用户手册页面:
 +
*http://www.linuxmanpages.com/
 +
* http://linux.man-pages.net
 +
*写你自己的用户手册页面:http://tldp.org/HOWTO/Man-Page/
 +
*维基百科中关于用户手册页面的文章:http://en.wikipedia.org/wiki/Unix_manual
 +
*man命令的用户手册页面:在命令行中输入<code><nowiki>man man</nowiki></code>。
 +
[[UbuntuHelp:UserDocumentation|用户文档]]
  
<br>
+
[[category:UbuntuHelp]]

2009年11月5日 (四) 14:27的最新版本


介绍

命令行程序man是用来显示Unix和Linux用户手册页面的。这些用户手册页面是储存在计算机硬盘上的完备的参考文献。它们通常很短小,但也可能很长。Ubuntu的用户手册系统为每个命令行程序都提供了参考手册,而且很多时候这也是该命令行程序的唯一参考资料的来源。Man使用分页程序来显示数据,分页程序是一种以文本终端来一屏一屏地显示文件的程序。在Ubuntu上,less就是所用到的分页程序。自从20世纪80年代,用户手册页面系统就是Unix和类Unix系统的一部分,虽然在今天的标准看来,它很原始,但它仍然是一个有用的资源。它为基于终端的命令行和程序(比如lsfindless,当然也包括man自身)提供了关于其可用的开关项和可选项的一种快速检索。另外,它还包含了你系统中绝大多数基于图形用户界面的程序的信息,如gimpfirefox。本页面描述了如何在命令行下使用man,并给出了用户手册系统的概述。本文内容不包含aproposwhatis命令,这两个命令都可用于搜索用户手册数据中的特定部分内容,而且它们都等效于使用了-k和-f开关项的man命令。但本页面覆盖了man命令的-k和-f开关项的内容。

使用Man命令

当你知道你想要查询的命令名或程序名时,你可以输入man <命令名>,像下面的例子所示的那样,这个例子向你展示了如何查看less命令的用户手册页面,用户手册系统正是用这个工具(less)来显示数据的。

jeffsch@mandela:~ man less
Reformatting less(1), please wait...

当用户手册页面打开后,使用上下箭头键和前后翻页键来浏览整个文件。按Q键来退出用户手册页面,返回到命令行状态。在文件中你可以用less的“/”命令来向前搜索,也可以用"?"命令来向後搜索。关于使用less的更多信息见它的用户手册页面。在上面的例子中,当用户手册页面正在後台被转化为一种适合于显示的格式时终端中会简要地显示一条消息“Reformatting less(1), please wait...”(正在转化less(1)的格式,请稍等...)。用户手册页面被分为9个主要的类别,被编号为1到9。上例的消息中的“(1)”部分指出所显示的用户手册页面属于第1类。 在本页面的最後给出了对不同用户手册页面分类的简要的说明。一个用户手册页面可能同时存在于两个或两个以上的分类中。例如man自身就有两个页面;一个在第1类中而另一个在第7类中。当你输入man man时,第1类中的页面会被显示。如果你想要查看第7类中的页面,则应输入man 7 man,正如下面的例子中所示范的一样。

jeffsch@mandela:~ man man
Reformatting man(1), please wait...
jeffsch@mandela:~ man 7 man
Reformatting man(7), please wait...

查找用户手册页面

使用man命令的-k和-f开关项来查找用户手册页面。你也可以使用独立地等效于man -kman -f命令的aproposwhatis命令。检索机制在你系统中的每个用户手册页面中查找,且每个页面只查找特定的一行。它所查找的那一行就在用户手册页面的NAME(名称)部分。用户手册页面被分为了几个部分,第1部分就是NAME(名称)部分。该部分包含了这个用户手册页面的名称和对该页面的主题所涉及到的内容的一个简短的描述。如果你的检索词没有出现在任何一个用户手册页面的NAME(名称)部分中,你的检索将返回零个结果。表1显示了一个典型的用户手册页面的前几行的一个实例,其中包括了NAME(名称)和SYNOPSIS(概要)部分以及DESCRIPTION(描述)部分的开头。

表1:ls命令的开头部分.
LS(1) LS(1)
NAME
ls - list directory contents
SYNOPSIS
ls [OPTION]... [FILE]...
DESCRIPTION
(此页面的剩余部分省略.)

man -k

当你用man命令的-k开关项来搜索用户手册页面时,每个用户手册页面的整个NAME(名称)部分都会被搜索而且搜索结果(如果有的话)会被显示。例如,如果你输入man -k find,你会得到类似于下表的一张明细表:

jeffsch@mandela:~$ man -k find
bogotune (1) - find optimum parameter settings for bogofilter
chkdupexe (1) - find duplicate executables
FcConfigFilename (3) - Find a config file
find (1) - search for files in a directory hierarchy
find2perl (1) - translate find command lines to Perl code
findfs (8) - Find a filesystem by label or UUID
gst-typefind-0.10 (1) - print MIME type of file
gst-typefind-0.8 (1) - print MIME type of file
mysql_find_rows (1) - MySQL shell skript for searching in update logs.
pidof (8) - find the process ID of a running program.
runlevel (8) - find the previous and current system runlevel.
sane-find-scanner (1) - find SCSI and USB scanners and their device files
XFindContext (3) - associative look-up routines
XtFindFile (3) - search for a file using substitutions in the path list
jeffsch@mandela:~$

请记住,只有每个用户手册页面的NAME(名称)部分会被搜索;如果你的检索词不在任何一个用户手册页面的NAME(名称)部分中,你的搜索就会返回零个结果。

man -f

当你用man命令的-k开关项来搜索时,只有用户手册页面的名字会被搜索。例如,如果你输入man -f find,你将得到如下所示的结果:

jeffsch@mandela:~$ man -f find
find (1) - search for files in a directory hierarchy
jeffsch@mandela:~$

用户手册页面的类别

用户手册页面被分为了9类,被编号为1到9。表2描述了这些分类。

表 2: 用户手册页面分类.
1 - 可执行程序或shell命令
2 - 系统调用 (由内核提供的函数)
3 - 库调用 (程序库里的函数)
4 - 特殊文件 (常指在 /dev路径下找到的文件)
5 - 文件格式和协议 例如 /etc/passwd
6 - 游戏
7 - 杂类文件 (包括宏软件包和协议), 例如 man(7), groff(7)
8 - 系统管理命令 (通常只有超级用户才能使用)
9 - 内核程序 [非标准]
资料来源: man(1)用户手册页面.

除了这些加了编号的分类之外,还有三个已经不再使用的分类,即字母n, o, 和 l。在新的用户手册系统中,我们已经不再使用这些分类了,但是你可能会在已经存在的文档和man命令的路径设置文件(/etc/manpath.config)中一次次地遇见它们。通过使用“扩展”,用户手册页面还可被细分为更小的类别。开发者和用户手册的作者比较关注这些小类别,而你则很有可能永远不用去管它,但你可以在man命令的用户手册页面中查找更多的相关信息。

资源

用户文档