1 |
r0bertz 08/03/01 06:25:23 |
2 |
|
3 |
Added: man-guide.xml |
4 |
Log: |
5 |
added man-guide.xml |
6 |
|
7 |
Revision Changes Path |
8 |
1.1 xml/htdocs/doc/zh_cn/man-guide.xml |
9 |
|
10 |
file : http://sources.gentoo.org/viewcvs.py/gentoo/xml/htdocs/doc/zh_cn/man-guide.xml?rev=1.1&view=markup |
11 |
plain: http://sources.gentoo.org/viewcvs.py/gentoo/xml/htdocs/doc/zh_cn/man-guide.xml?rev=1.1&content-type=text/plain |
12 |
|
13 |
Index: man-guide.xml |
14 |
=================================================================== |
15 |
<?xml version="1.0" encoding="UTF-8"?> |
16 |
<!DOCTYPE guide SYSTEM "/dtd/guide.dtd"> |
17 |
<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/zh_cn/man-guide.xml,v 1.1 2008/03/01 06:25:22 r0bertz Exp $ --> |
18 |
<!-- English CVS version: 1.5 --> |
19 |
<guide link="/doc/zh_cn/man-guide.xml" lang="zh_cn"> |
20 |
<title>Gentoo man手册指南</title> |
21 |
|
22 |
<author title="作者"> |
23 |
<mail link="chriswhite@g.o">Chris White</mail> |
24 |
</author> |
25 |
|
26 |
<author title="译者"> |
27 |
<mail link="jjmmma@×××××.com">马吉军</mail> |
28 |
</author> |
29 |
|
30 |
<abstract> |
31 |
这篇指南帮助你如何使用man浏览man手册。 |
32 |
</abstract> |
33 |
|
34 |
<!-- The content of this document is licensed under the CC-BY-SA license --> |
35 |
<!-- See http://creativecommons.org/licenses/by-sa/2.5 --> |
36 |
<license/> |
37 |
|
38 |
<version>2</version> |
39 |
<date>2006-06-18</date> |
40 |
|
41 |
<chapter> |
42 |
<title>简介</title> |
43 |
<section> |
44 |
<title>man程序</title> |
45 |
<body> |
46 |
|
47 |
<p> |
48 |
每一个人在他的linux人生中都使用过它。它就是<c>man</c>命令。尽管man程序本身的结构看起来非常简单,然而,它除了滚动手册页之外,还有一些其他额外的功能。希望这篇文档能为你点亮man的那些功能。 |
49 |
</p> |
50 |
|
51 |
</body> |
52 |
</section> |
53 |
<section> |
54 |
<title>Man结构</title> |
55 |
<body> |
56 |
|
57 |
<p> |
58 |
手册页主要报存在<path>/usr/share/man</path>目录下。 |
59 |
其实,只要是列在<c>MANPATH</c>环境变量的路径中的手册页,man都能够找到。Gentoo一般将<c>MANPATH</c>变量保存在<path>/etc/env.d</path>中。在这些目录中,保存了一些结构为manX的文件夹。其中X表示章节号。一个标准的man布局可能如下所示: |
60 |
</p> |
61 |
|
62 |
<pre caption="标准man结构"> |
63 |
$ <i>ls /usr/share/man | grep man</i> |
64 |
man0p |
65 |
man1 |
66 |
man1p |
67 |
man2 |
68 |
man3 |
69 |
man3p |
70 |
man4 |
71 |
man5 |
72 |
man6 |
73 |
man7 |
74 |
man8 |
75 |
man9 |
76 |
mann |
77 |
</pre> |
78 |
|
79 |
<p> |
80 |
实际的章节号显示的很标准,但是注意这里有一个<path>mann</path>和几个<path>man#p</path>文件夹。下表列举了上面man目录,以及其中包含了什么: |
81 |
</p> |
82 |
|
83 |
<table> |
84 |
<tr> |
85 |
<th>man目录</th> |
86 |
<th>描述</th> |
87 |
</tr> |
88 |
<tr> |
89 |
<ti>man0p</ti> |
90 |
<ti> |
91 |
和其他有目录名中有p的目录一样,这个<c>p</c>表示POSIX。在这个目录下的手册页描述各种POSIX头文件的功能。 |
92 |
</ti> |
93 |
</tr> |
94 |
<tr> |
95 |
<ti>man1</ti> |
96 |
<ti> |
97 |
这一章节介绍标准命令。大部分程序将其手册页放在这里。因此,这一章节将会是最大的。 |
98 |
</ti> |
99 |
</tr> |
100 |
<tr> |
101 |
<ti>man1p</ti> |
102 |
<ti> |
103 |
这一章节描述POSIX版本的命令。因为这里只描述基本的命令,因此会比man1小很多。 |
104 |
</ti> |
105 |
</tr> |
106 |
<tr> |
107 |
<ti>man2</ti> |
108 |
<ti>这一章节描述Linux内核系统调用。</ti> |
109 |
</tr> |
110 |
<tr> |
111 |
<ti>man3</ti> |
112 |
<ti>这一章节描述标准的c函数库。</ti> |
113 |
</tr> |
114 |
<tr> |
115 |
<ti>man4</ti> |
116 |
<ti> |
117 |
这一章节描述特殊的设备。这些设备通常是面向内核的,不过<c>Xorg-X11</c>在这里也有一项。 |
118 |
</ti> |
119 |
</tr> |
120 |
<tr> |
121 |
<ti>man5</ti> |
122 |
<ti> |
123 |
这一章节描述一些特定文件的结构以及程序将使用哪些文件。读者们可能对以下参考比较熟悉,<c>man 5 portage</c>是对<c>portage</c>文件结构的一些描述,还有<c>man 5 make.conf</c>是对<path>make.conf</path>文件结构的描述。 |
124 |
</ti> |
125 |
</tr> |
126 |
<tr> |
127 |
<ti>man6</ti> |
128 |
<ti>这一章节介绍游戏和一些特殊玩具。</ti> |
129 |
</tr> |
130 |
<tr> |
131 |
<ti>man7</ti> |
132 |
<ti> |
133 |
这一章节描述一些标准和一些杂项。标准包括比如字符集,SQL语句,ISO标准以及正则表达式。 |
134 |
</ti> |
135 |
</tr> |
136 |
<tr> |
137 |
<ti>man8</ti> |
138 |
<ti> |
139 |
这一章节描述管理员命令(通常由root用户执行的那些命令)。 |
140 |
</ti> |
141 |
</tr> |
142 |
<tr> |
143 |
<ti>man9</ti> |
144 |
<ti> |
145 |
这一章节很少。应该是包含内核一些部分的文档。 |
146 |
</ti> |
147 |
</tr> |
148 |
<tr> |
149 |
<ti>mann</ti> |
150 |
<ti> |
151 |
这一章节主要包含<c>Tcl/Tk</c>的一些文档。<c>n</c>表示新的(new)。 |
152 |
</ti> |
153 |
</tr> |
154 |
</table> |
155 |
|
156 |
<p> |
157 |
尽管不是全部的细节,这里列举了大部分人感兴趣的手册页。然而,当你想了解某个章节是干什么的,查查这张表格是最快捷的方法了。下一章介绍如何通过man遍历这里介绍的man结构。 |
158 |
</p> |
159 |
|
160 |
</body> |
161 |
</section> |
162 |
</chapter> |
163 |
|
164 |
<chapter> |
165 |
<title>使用man结构</title> |
166 |
<section> |
167 |
<title>浏览man结构</title> |
168 |
<body> |
169 |
|
170 |
<p> |
171 |
现在我们知道了标准的man结构。我们开始通过命令查看。有时候我们希望减小我们的查找手册页的范围。第一种方法是通过指定章节。比如找出对man中的章节的描述,我们可以使用<c>man 章节号 intro</c>: |
172 |
</p> |
173 |
|
174 |
<pre caption="使用man intro找到章节号的描述"> |
175 |
$ <i>man 3 intro</i> |
176 |
<comment>(为了适合这个文档,我们稍微修改了一下输出)</comment> |
177 |
INTRO(3) Linux Programmer's Manual INTRO(3) |
178 |
|
179 |
|
180 |
|
181 |
NAME |
182 |
intro - Introduction to library functions |
183 |
|
184 |
DESCRIPTION |
185 |
This chapter describes all library functions excluding the library |
186 |
functions described in chapter 2, which implement system calls. |
187 |
There are various function groups which can be identified by a |
188 |
letter which is appended to the chapter number: |
189 |
.... |
190 |
</pre> |
191 |
|
192 |
<p> |
193 |
遗憾的是,这样做不一定行!幸运的是,我们可以通过另外一种方法查找那些可能有多个返回结构的命令(比如一个库调用和系统命令有相同的命令时)。我们用<c>-K</c>参数,比如: |
194 |
</p> |
195 |
|
196 |
<pre caption="使用man -K查找字符串"> |
197 |
$ <i>man -K sleep</i> |
198 |
/usr/share/man/man0p/time.h.0p.gz? [ynq] <i>n</i> |
199 |
/usr/share/man/man0p/unistd.h.0p.gz? [ynq] <i>n</i> |
200 |
/usr/share/man/man2/alarm.2.gz? [ynq] <i>n</i> |
201 |
/usr/share/man/man2/pause.2.gz? [ynq] <i>n</i> |
202 |
/usr/share/man/man2/futex.2.gz? [ynq] <i>n</i> |
203 |
/usr/share/man/man2/nanosleep.2.gz? [ynq] <i>y</i> |
204 |
/usr/share/man/man2/semop.2.gz? [ynq] <i>q</i> |
205 |
</pre> |
206 |
|
207 |
<p> |
208 |
有时候输出结果可能会很多。这时候最好指定更确切的关键字。现在我们知道怎么找到手册页了。接下来的章节介绍怎么查看手册页。 |
209 |
</p> |
210 |
|
211 |
</body> |
212 |
</section> |
213 |
<section> |
214 |
<title>查看手册页</title> |
215 |
<body> |
216 |
|
217 |
<p> |
218 |
查看手册页有两种方法。方法一,<c>man [手册页名字]</c>。方法二,<c>man |
219 |
[章节] [手册页名字]</c>。我们以<c>bc</c>为例子。我们可以查看到第一篇关于<c>bc</c>的手册页(章节号将会是1,因为这是章节号最小的包含<c>bc</c>命令的章节): |
220 |
</p> |
221 |
|
222 |
<pre caption="查看默认手册页"> |
223 |
$ <i>man bc</i> |
224 |
bc(1) bc(1) |
225 |
|
226 |
|
227 |
NAME |
228 |
bc - An arbitrary precision calculator language |
229 |
... |
230 |
</pre> |
231 |
|
232 |
<p> |
233 |
然而,如果我们要找POSIX版的呢?那么我可以用第二种形式: |
234 |
</p> |
235 |
|
236 |
<pre caption="查看特定章节中的手册页"> |
237 |
$ <i>man 1p bc</i> |
238 |
BC(P) POSIX Programmer's Manual BC(P) |
239 |
|
240 |
|
241 |
NAME |
242 |
bc - arbitrary-precision arithmetic language |
243 |
... |
244 |
</pre> |
245 |
|
246 |
<p> |
247 |
手册页显示如上。现在我们查看到了手册页,接下来是怎么在上面工作。下一章介绍如何浏览和搜索。 |
248 |
</p> |
249 |
|
250 |
</body> |
251 |
</section> |
252 |
<section> |
253 |
<title>浏览和搜索手册页</title> |
254 |
<body> |
255 |
|
256 |
<p> |
257 |
浏览手册页非常简单。使用向上和向下键一行一行翻阅。使用向上翻页和向下翻页键一页一页翻阅。注意,使用这样的浏览指令是假设环境变量<c>PAGER</c>设成了默认的<c>less</c>。less还有其他一些浏览命令。不过方向键一般足够了。 |
258 |
</p> |
259 |
|
260 |
<pre caption="另外的less浏览键"> |
261 |
e ^E j ^N CR * 前进一行(或N行) |
262 |
y ^Y k ^K ^P * 后退一行(或N行) |
263 |
f ^F ^V SPACE * 前进一个窗口(或N行) |
264 |
b ^B ESC-v * 后退一个窗口(或N行) |
265 |
z * 前进一个窗口(将窗口设置到N) |
266 |
w * 后退一个窗口(将窗口设置到N) |
267 |
ESC-SPACE * 前进一个窗口,在文件末尾不停止 |
268 |
d ^D * 前进半个窗口(将这半个窗口设置到N) |
269 |
u ^U * 后退半个窗口(将这半个窗口设置到N) |
270 |
ESC-) RightArrow * 向左半个屏幕宽(或N个位置) |
271 |
ESC-( LeftArrow * 向右半个屏幕宽(或N个位置) |
272 |
F 一直前进,像"tail -f"一样 |
273 |
</pre> |
274 |
|
275 |
<p> |
276 |
搜索更加有趣。最基本的搜索指令是 |
277 |
<c>/字符串</c>和<c>?字符串</c>。 |
278 |
第一个版本向前搜索,第二个版本向后搜索。 |
279 |
这里的<c>字符串</c>是正则表达式字符串,在n<c>man 7 regex</c>中有描述。 |
280 |
我们以搜索<c>emerge</c>的<c>-D</c>为例,首先找出emerge的手册页: |
281 |
</p> |
282 |
|
283 |
<pre caption="找出emerge的手册页"> |
284 |
$ <i>man emerge</i> |
285 |
</pre> |
286 |
|
287 |
<p> |
288 |
然后,在屏幕上,按<c>/</c>就能显示出向前搜索的提示。我们输入搜索字符串: |
289 |
</p> |
290 |
|
291 |
<pre caption="显示向前搜索提示"> |
292 |
gracefully handles updating installed packages to newer releases as well. |
293 |
It handles both source and binary packages, and it can be used to create |
294 |
binary packages for distribution. |
295 |
|
296 |
EBUILDS, TBZ2S, CLASSES AND DEPENDENCIES |
297 |
/<i>\-D</i> |
298 |
</pre> |
299 |
|
300 |
<note> |
301 |
<c>\</c>符号使用来换码<c>-</c>符号。<c>\</c>一般用作正则表达式的一部分。 |
302 |
</note> |
303 |
|
304 |
<p> |
305 |
这将搜索手册页,然后将锁定到被搜索的项: |
306 |
</p> |
307 |
|
308 |
<pre caption="向前搜索结果"> |
309 |
--deep (-D) |
310 |
When used in conjunction with --update, this flag forces emerge to consider the entire |
311 |
dependency tree of packages, instead of checking only the immediate dependencies of |
312 |
the packages. As an example, this catches updates in libraries that are not directly |
313 |
listed in the dependencies of a package. |
314 |
</pre> |
315 |
|
316 |
<p> |
317 |
如果你你搜索到结果之后还想再继续搜索同样的字符串,只要再次按<c>/</c>键,然后回车(即,不要再输入搜索字符串)就可以了。 |
318 |
这将默认搜索上一次使用的搜索字符串。现在已经找到我们搜索的选项的手册页,上面解释了选项含义。 |
319 |
再比如<c>man 5 portage</c>手册页。上面列了使用到的文件并解释了其用途。向前搜索几次就能找到结果,不过也有一个简单的方法 |
320 |
来处理这个问题。用第二个搜索方法向后搜索。我们用这个方法查找<path>package.unmask</path>的描述。首先显示<c>man 5 portage</c>手册页: |
321 |
</p> |
322 |
|
323 |
<pre caption="显示man 5 portage手册页"> |
324 |
$ <i>man 5 portage</i> |
325 |
</pre> |
326 |
|
327 |
<p> |
328 |
然后按<c>SHIFT+g</c>,将把你带到手册页末尾: |
329 |
</p> |
330 |
|
331 |
<pre caption="按SHIFT+g之后到达手册页末尾"> |
332 |
SEE ALSO |
333 |
emerge(1), ebuild(1), ebuild(5), make.conf(5) |
334 |
|
335 |
Portage 2.0.51 Jan 2004 PORTAGE(5) |
336 |
lines 418-442/442 (END) |
337 |
</pre> |
338 |
|
339 |
<p> |
340 |
现在,我们继续用<c>?字符串</c>方法向后搜索选项。首先按<c>?</c>键显示出搜索提示,然后输入<c>package.unmask</c>回车,我们这样查询: |
341 |
</p> |
342 |
|
343 |
<pre caption="指定我们的搜索"> |
344 |
SEE ALSO |
345 |
emerge(1), ebuild(1), ebuild(5), make.conf(5) |
346 |
|
347 |
Portage 2.0.51 Jan 2004 PORTAGE(5) |
348 |
?<i>package.unmask</i> |
349 |
</pre> |
350 |
|
351 |
<p> |
352 |
然后按回车显示出搜索结果: |
353 |
</p> |
354 |
|
355 |
<pre caption="我们的搜索结果"> |
356 |
package.unmask |
357 |
Just like package.mask above, except here you list packages you want to unmask. |
358 |
Useful for overriding the global package.mask file (see below). Note that |
359 |
this does not override packages that are masked via KEYWORDS. |
360 |
... |
361 |
</pre> |
362 |
|
363 |
<p> |
364 |
搜索完成!注意,和使用<c>/</c>一样,用<c>?</c>搜索时,不输入搜索字符串会默认用上一次搜索字符串。 |
365 |
</p> |
366 |
|
367 |
</body> |
368 |
</section> |
369 |
<section> |
370 |
<title>结论</title> |
371 |
<body> |
372 |
|
373 |
<p> |
374 |
这一章总结man指导。希望这篇指导点亮手册页浏览的一线曙光,并给有经验的用户一点新的提示。 |
375 |
喜欢用其他方法浏览手册页的用户也可以用以下工具: |
376 |
</p> |
377 |
|
378 |
<ul> |
379 |
<li>app-text/man2html - 一个将手册页转成html的程序</li> |
380 |
<li>app-text/tkman - 一个基于tk的手册页浏览器</li> |
381 |
</ul> |
382 |
|
383 |
<p> |
384 |
<c>KDE</c>的网页浏览器<c>Konqueror</c>也能用来浏览手册页。只要在地址条上输入<c>man:</c>。 |
385 |
</p> |
386 |
|
387 |
</body> |
388 |
</section> |
389 |
</chapter> |
390 |
</guide> |
391 |
|
392 |
|
393 |
|
394 |
-- |
395 |
gentoo-commits@l.g.o mailing list |