一、man(使用手册)
man是manual的简写,manual是手册的意思~
1、NAME(说明)
man - format and display the on-line manual pages
查看格式和显示在线手册页。有任何不明白的命令,就可以用这个命令查看使用和说明。
举例:
man cd
按 q 退出查看模式。
我们输入 man ls,它会在最左上角显示“LS(1)”,在这里,“LS”表示手册名称,而“(1)”表示该手册位于第一节章,同样,我们输入“man ifconfig”它会在最左上角显示“IFCONFIG(8)”。也可以这样输入命令:“man [章节号] 手册名称”。
man是按照手册的章节号的顺序进行搜索的,比如:
man sleep
image.png
只会显示sleep命令的手册,如果想查看库函数sleep,就要输入:
man 3 sleep
image.png
ubuntu默认是没有安装c语言的库函数man手册的
- 让man显示中文
ubuntu源里面已经包含了中文的man包,所以不用从其他地方down了,直接
sudo apt-get install manpages-zh
但是这样man默认显示的还不是中文,还需要以下两步
a.把中文man包转换成utf8格式的
新建一个脚本文件
gedit t.sh
把下面内容添加进去
#!/bin/bashcd /usr/share/man/zh_CN/for k in *docd $kfor i in *.gzdo j=`echo ${i%.gz}` gunzip $i iconv -f gb18030 -t utf8 $j >tmp mv tmp $j gzip $jdonecd ..done
然后
sudo ./t
b.修改man默认的语言
sudo gedit /etc/manpath.config 把里面的所有的 /usr/share/man 改成 /usr/share/man/zh_CN
保存后退出,然后你再试一下man ls
- 让没有中文帮助的显示英文
做完上面第二部还不够,这时你再man 一下一些c语言函数(不要用printf,socket之类比较有名的函数,这些已经有中文帮助了)的时候就会发现竟然没有帮助,而刚才明明在第一步已经安装了啊。这是因为你上面 把/usr/share/man 改成 /usr/share/man/zh_CN的操作使man只在中文帮助中搜索,如果没有就直接放弃,因此还需要以下操作,才能让man在没有中文帮助的时候自动显示英文的帮助,如果英文的也没有,哪就真的没有了。
sudo gedit /etc/manpath.config
然后搜索你刚才改过的地方,然后在其后面添加同样的一行,只是后面的目录还用原来的/usr/share/man,比如在修改后的
MANPATH_MAP /bin /usr/share/man/zh_CN
再添加一行
MANPATH_MAP /bin /usr/share/man
新安装了ubuntu 8.04版本,发现安装过的系统中缺少很多手册页。
用以下命令搞定了
sudo apt-get install manpages
sudo apt-get install manpages-de
sudo apt-get install manpages-de-dev
sudo apt-get install manpages-dev
2、SYNOPSIS(剧情简介)
man [-acdfFhkKtwW] [--path] [-m system] [-p string] [-C config_file] [-M path-
list] [-P pager] [-B browser] [-H htmlpager] [-S section_list] [section] name
...
3、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 speci-
fication, so that you can do man ./foo.5 or even man /cd/foo/bar.1.gz.
手册可查看格式和显示在线手册页。如果您指定部分,man命令可查看部分手册。名字通常是名称的手册页,这通常是一个命令的名字,函数,或文件。然而,如果名称包含斜杠(/)然后speci——手册把它解释为一个文件,所以你可以使用命令如:man ./foo.5 或者 man /cd/foo/bar.1.gz。
See below for a description of where man looks for the manual page files.
手册详见手册页下文的描述文件。
4、OPTIONS(选项)
-C config_file 配置文件
Specify the configuration file to use; the default is /private/etc/man.conf. (See man.conf(5).)
指定要使用的配置文件;默认的配置文件是/private/etc/man.conf。(详见man.conf(5))
-M path 路径
Specify the list of directories to search for man pages. Separate the
directories with colons. An empty list is the same as not specifying
-M at all. See SEARCH PATH FOR MANUAL PAGES.
指定搜索手册页的目录列表。分离目录与冒号。一个空的列表是一样的没有指定- m。查看手册页搜索路径。
-P pager 寻呼机
Specify which pager to use. This option overrides the MANPAGER envi-
ronment variable, which in turn overrides the PAGER variable. By
default, man uses /usr/bin/less -is.
指定使用哪个寻呼机。这个选项覆盖了从环境-律变量,进而覆盖寻呼机变量。默认情况下,使用/usr/bin/less -is。
-B
Specify which browser to use on HTML files. This option overrides the
BROWSER environment variable. By default, man uses /usr/bin/less-is,
指定使用哪个浏览器在HTML文件。这个选项覆盖浏览器环境变量。
默认情况下,使用/usr/bin/less-is。
-H
Specify a command that renders HTML files as text. This option over-
rides the HTMLPAGER environment variable. By default, man uses
/bin/cat,
指定一个命令作为文本呈现的HTML文件。这个选项,HTMLPAGER环境变量。默认情况下,使用/bin/cat。
-S section_list 部分列表
List is a colon separated list of manual sections to search. This
option overrides the MANSECT environment variable.
列表是一个冒号分隔的列表搜索手册部分。这选择覆盖MANSECT环境变量。
-a
By default, man will exit after displaying the first manual page it
finds. Using this option forces man to display all the manual pages
that match name, not just the first.
默认情况下,手册会在退出后显示发现的第一个手册页面。使用此选项来显示所有手册中与名字相匹配的页面,而不是第一个。
-c
Reformat the source man page, even when an up-to-date cat page exists.
This can be meaningful if the cat page was formatted for a screen with
a different number of columns, or if the preformatted page is cor-
rupted.
重新格式化源手册页,即使一个最新的cat页面存在。这可能是有意义的,如果cat页面格式化为一个屏幕不同的列数,或者共同格式化页面表“断裂”。
-d
Don't actually display the man pages, but do print gobs of debugging
information.
实际上并不显示手册页,但是打印大量的调试信息。
-D
Both display and print debugging info.
同时显示手册和打印调试信息。
-f
Equivalent to whatis.
相当于01。
-F or --preformat 预先格式
Format only - do not display.
格式- - -不显示。
-h
Print a help message and exit.
打印帮助消息并退出。
-k
Search for the specified string in all man pages. Warning: this is
probably very slow! It helps to specify a section. (Just to give a
rough idea, on my machine this takes about a minute per 500 man pages.)
搜索指定的字符串在*所有 *手册页。警告:这是可能非常缓慢!它有助于指定一个部分。(给一个粗略的想法,在我的机器上,这需要大约一分钟每500手册页)。
-m system 系统
Specify an alternate set of man pages to search based on the system
name given.
指定一个基于系统名字搜索的替代的手册页。
-p string 字符串
Specify the sequence of preprocessors to run before nroff or troff.
Not all installations will have a full set of preprocessors. Some of
the preprocessors and the letters used to designate them are: eqn (e),
grap (g), pic (p), tbl (t), vgrind (v), refer (r). This option over-
rides the MANROFFSEQ environment variable.
指定的顺序预处理器nroff或troff之前运行。并不是所有的安装将会有一个完整的预处理器。一些预处理器,用于指定的字母是:eqn (e),grap (g),pic(p),tbl(t) ,vgrind (v) , refer(r)。这个选项MANROFFSEQ环境变量。
-t
Use /usr/bin/groff -Tps -mandoc -c to format the manual page, passing
the output to stdout. The default output format of /usr/bin/groff -Tps
-mandoc -c is Postscript, refer to the manual page of /usr/bin/groff
-Tps -mandoc -c for ways to pick an alternate format.
使用/usr/bin/groff -Tps -mandoc -c格式手册页面,通过输出到标准输出。默认输出格式/usr/bin/groff -Tps -mandoc -c,手册页另一种格式/usr/bin/groff -Tps -mandoc -c。
Depending on the selected format and the availability of printing devices, the
output may need to be passed through some filter or another before being
printed.
根据所选的格式和打印设备的可用性,输出可能需要通过某种过滤器之前打印出来。
-w or --path
Don't actually display the man pages, but do print the location(s) of
the files that would be formatted or displayed. If no argument is
given: display (on stdout) the list of directories that is searched by
man for man pages. If manpath is a link to man, then "manpath" is
equivalent to "man --path".
不显示手册页,但打印的位置将格式化的或显示的文件。如果没有参数鉴于:显示(stdout)搜索的目录列表手册页。如果手册路径链接到一个手册,然后“手册路径”相当于“手册——路径”。
-W
Like -w, but print file names one per line, without additional informa-
tion. This is useful in shell commands like man -aW man | xargs ls -l
就像 -w,但每行打印文件的名字,没有额外的信息。这像是在shell里用命令man -aW man | xargs ls -l。
5、CAT PAGES(作者个人理解是concatenate pages的意思,就是 连接页面)
Man will try to save the formatted man pages, in order to save formatting time
the next time these pages are needed. Traditionally, formatted versions of
pages in DIR/manX are saved in DIR/catX, but other mappings from man dir to
cat dir can be specified in /private/etc/man.conf. No cat pages are saved
when the required cat directory does not exist. No cat pages are saved when
they are formatted for a line length different from 80. No cat pages are
saved when man.conf contains the line NOCACHE.
man将试图保存格式化的手册页,为了节省时间保存格式化的页面是必要的。传统上,格式化的版本页面在DIR/manX(某个路径下的手册),但其他映射可以指定在/private/etc/man.conf。没有连接的页面保存当连接所需的目录不存在。不保存,当连接页面他们是格式化线长度不同于80。当man.conf 包含了NOCACHE时没有连接的页面手册被保存。
It is possible to make man suid to a user man. Then, if a cat directory has
owner man and mode 0755 (only writable by man), and the cat files have owner
man and mode 0644 or 0444 (only writable by man, or not writable at all), no
ordinary user can change the cat pages or put other files in the cat direc-
tory. If man is not made suid, then a cat directory should have mode 0777 if
all users should be able to leave cat pages there.
可以对一个用户使用man suid。然后,如果一个连接目录拥有者与模式0755(只可写的人),和连接文件所有者手册和模式0644或0444(只可写的人,或没有可写的),没有普通用户可以改变连接页面或把其他文件放在连接文件。如果man的不是suid,那么应该模式0777如果一个连接目录所有的用户应该能够离开连接页面。
The option -c forces reformatting a page, even if a recent cat page exists.
选项- c强制重新格式化页面,即使最近的连接页面存在。
6、HTML PAGES(HTML页面)
Man will find HTML pages if they live in directories named as expected to be
".html", thus a valid name for an HTML version of the ls(1) man page would be
/usr/share/man/htmlman1/ls.1.html.
手册会发现HTML页面,如果他们所在目录命名为.html,因此一个有效名字的html版本的ls(1)手册页是/usr/share/man/htmlman1/ls.1.html.
7、SEARCH PATH FOR MANUAL PAGES(手册页的搜索路径)
man uses a sophisticated method of finding manual page files, based on the
invocation options and environment variables, the /private/etc/man.conf con-
figuration file, and some built in conventions and heuristics.
手册使用一个复杂的方法找到手册页的文件,根据调用选项和环境变量/private/etc/man.conf。相依共同配置文件,有些建在约定和启发式。
First of all, when the name argument to man contains a slash (/), man assumes
it is a file specification itself, and there is no searching involved.
首先,当参数名称包含一个斜杠(/),假设文件规范本身,没有搜索。
But in the normal case where name doesn't contain a slash, man searches a
variety of directories for a file that could be a manual page for the topic
named.
但在正常情况下名称不包含一个斜杠,搜索一个手册各种各样的目录文件,可以手动页面为主题命名。
If you specify the -M pathlist option, pathlist is a colon-separated list of
the directories that man searches.
如果你指定- m pathlist选项,pathlist以冒号分隔的手册搜索的目录。
If you don't specify -M but set the MANPATH environment variable, the value of
that variable is the list of the directories that man searches.
如果没有指定- m但设置MANPATH环境变量的值这个变量是手册搜索的目录列表。
If you don't specify an explicit path list with -M or MANPATH, man develops
its own path list based on the contents of the configuration file /pri-
vate/etc/man.conf. The MANPATH statements in the configuration file identify
particular directories to include in the search path.
如果你不指定一个明确的路径列表- m和MANPATH,手册会用自己的路径列表基于配置文件的内容/private/etc/man.conf。在配置文件中确定的MANPATH语句特定的目录中包含搜索路径。
Furthermore, the MANPATH_MAP statements add to the search path depending on
your command search path (i.e. your PATH environment variable). For each
directory that may be in the command search path, a MANPATH_MAP statement
specifies a directory that should be added to the search path for manual page
files. man looks at the PATH variable and adds the corresponding directories
to the manual page file search path. Thus, with the proper use of MAN-
PATH_MAP, when you issue the command man xyz, you get a manual page for the
program that would run if you issued the command xyz.
此外,根据MANPATH_MAP语句添加到搜索路径你的命令搜索路径(即你的path环境变量)。为每一个目录可能在命令搜索路径,MANPATH_MAP语句指定一个目录应手动页面添加到搜索路径文件。手册看着PATH变量,增加了相应的目录手册页文件搜索路径。因此,手册的正确使用PATH_MAP,当你发出该命令手册xyz,得到的手册页程序会运行如果你发布命令xyz。
In addition, for each directory in the command search path (we'll call it a
"command directory") for which you do not have a MANPATH_MAP statement, man
automatically looks for a manual page directory "nearby" namely as a subdirec-
tory in the command directory itself or in the parent directory of the command
directory.
此外,对于每个目录的命令搜索路径(我们叫它“命令目录”)你没有MANPATH_MAP声明,手册自动查找手册页目录即subdirec——“附近”保守党在命令目录本身或父目录的命令目录中。
You can disable the automatic "nearby" searches by including a NOAUTOPATH
statement in /private/etc/man.conf.
你可以禁用自动搜索的“附近”包括NOAUTOPATH声明在/private/etc/man.conf。
In each directory in the search path as described above, man searches for a
file named topic.section, with an optional suffix on the section number and
possibly a compression suffix. If it doesn't find such a file, it then looks
in any subdirectories named manN or catN where N is the manual section number.
If the file is in a catN subdirectory, man assumes it is a formatted manual
page file (cat page). Otherwise, man assumes it is unformatted. In either
case, if the filename has a known compression suffix (like .gz), man assumes
it is gzipped.
在每个目录搜索路径如上所述,搜索一个手册文件命名为主题。部分,一个可选的部分数量和后缀可能是压缩后缀。如果没有找到这样一个文件,然后它的样子在任何子目录命名为曼或catN其中N是手动部分号码。如果catN子目录中的文件,手册认为这是一个格式化的手册页面文件(连接页面)。否则,手册假设是无格式。在这两种情况下,如果文件名有已知的压缩后缀(比如. gz),假设这是gzip。
If you want to see where (or if) man would find the manual page for a particu-
lar topic, use the --path (-w) option.
如果你想看手册的主题,使用--path (-w)选项。
8、ENVIRONMENT(环境)
- MANPATH(主路径)
If MANPATH is set, man uses it as the path to search for manual page
files. It overrides the configuration file and the automatic search
path, but is overridden by the -M invocation option. See SEARCH PATH
FOR MANUAL PAGES.
如果设置了MANPATH,手册使用它作为路径搜索手册页文件。它覆盖配置文件和自动搜索路径,但被调用- m选项。详见搜索路径手册页。
9、BUGS(错误)
The -t option only works if a troff-like program is installed.
If you see blinking \255 or <AD> instead of hyphens, put `LESSCHARSET=latin1'
in your environment.
- t选项只适用如果troff-like程序安装。如果你看到闪烁\ 255或<广告>连字符,而是把' LESSCHARSET = latin1”中的一个在您的环境中。
10、TIPS(提示)
If you add the line
如果您添加
(global-set-key [(f1)] (lambda () (interactive) (manual-entry (current-
word))))
to your .emacs file
到你的.emacs文件。
then hitting F1 will give you the man page for the
library call at the current cursor position.
然后按F1会给你的手册页库调用在当前光标位置。
To get a plain text version of a man page, without backspaces and underscores,
try
得到一个纯文本版本的手册页,没有退格和下划线,试一试
man foo | col -b > foo.mantxt
11、AUTHOR(作者)
John W. Eaton was the original author of man.
约翰·w·伊顿是手册的原作者。
网友评论