每天一个linux命令(70):man命令

来源:互联网 发布:指南针mc指标源码 编辑:程序博客网 时间:2024/06/06 07:21
Linux提供了丰富的帮助手册,当你需要查看某个命令的参数时不必到处上网查找,只要man一下即可。

Linux的man手册共有以下几个章节:

代號代表內容1使用者在shell中可以操作的指令或可执行档2系統核心可呼叫的函数与工具等3一些常用的函数(function)与函数库(library),大部分是C的函数库(libc)4装置档案的说明,通常在/dev下的档案5设定档或者是某些档案的格式6游戏(games)7惯例与协定等,例如Linux档案系统、网络协定、ASCII code等等的說明8系統管理員可用的管理指令9跟kernel有关的文件

如:man 5 data


1 Executable programs or shell commands
2 System calls (functions provided by the kernel)
3 Library calls (functions within program libraries)
4 Special files (usually found in /dev)
5 File formats and conventions eg /etc/passwd
6 Games
7 Miscellaneous (including macro packages and conventions), e.g. man(7), groff(7)
8 System administration commands (usually only for root)
9 Kernel routines [Non standard]



1、Standard commands (标准命令)
2、System calls (系统调用)
3、Library functions (库函数)
4、Special devices (设备说明)
5、File formats (文件格式)
6、Games and toys (游戏和娱乐)
7、Miscellaneous (杂项)
8、Administrative Commands (管理员命令)
9 其他(Linux特定的), 用来存放内核例行程序的文档。

n 新文档, 可能要移到更适合的领域。
o 老文档, 可能会在一段期限内保留。
l 本地文档, 与本特定系统有关的。

例如:我们输入 man ls,它会在最左上角显示“LS(1)”,在这里,“LS”表示手册名称,而“(1)”表示该手册位于第一节章,同样,我们输入“man ifconfig”它会在最左上角显示“IFCONFIG(8)”。也可以这样输入命令:“man [章节号] 手册名称”。

man是按照手册的章节号的顺序进行搜索的,比如:
man sleep
只会显示sleep命令的手册,如果想查看库函数sleep,就要输入:
man 3 sleep


ubuntu默认是没有安装c语言的库函数man手册的

1.添加库函数手册
ubuntu默认是没有安装c语言的库函数man手册的,所以你在man perror 和sendto之类的函数时会显示没有相关文档的问题,这个问题让我郁闷了我好久。解决方法:
sudo apt-get install manpages-dev
2.让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
3.让没有中文帮助的显示英文
做完上面第二部还不够,这时你再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

 
-C, --config-file=文件   使用该用户设置文件  -d, --debug                输出调试信息  -D, --default              将所有选项都重置为默认值      --warnings[=警告]    开启 groff 的警告 主要运行模式:  -f, --whatis               等同于 whatis  -k, --apropos              等同于 apropos  -K, --global-apropos       search for text in all pages  -l, --local-file                             把“手册页”参数当成本地文件名来解读  -w, --where, --path, --location                             输出手册页的物理位置  -W, --where-cat, --location-cat                             输出 cat 文件的物理位置  -c, --catman               由 catman 使用,用来对过时的 cat                             页重新排版  -R, --recode=编码        output source page encoded in ENCODING 寻找手册页:  -L, --locale=区域                             定义本次手册页搜索所采用的区域设置  -m, --systems=系统       use manual pages from other systems  -M, --manpath=路径       设置搜索手册页的路径为“路径”  -S, -s, --sections=列表  使用以半角冒号分隔的章节列表  -e, --extension=扩展                             将搜索限制在扩展类型为“扩展”的手册页之内  -i, --ignore-case          查找手册页时不区分大小写字母                             (默认)  -I, --match-case           查找手册页时区分大小写字母。      --regex                show all pages matching regex      --wildcard             show all pages matching wildcard      --names-only           make --regex and --wildcard match page names only,                             not descriptions  -a, --all                  寻找所有匹配的手册页  -u, --update               强制进行缓存一致性的检查      --no-subpages          don't try subpages, e.g. 'man foo bar' => 'man                             foo-bar' 控制格式化的输出:  -P, --pager=PAGER          使用 PAGER 程序显示输出文本  -r, --prompt=字符串     给 less pager 提供一个提示行  -7, --ascii                显示某些 latin1 字符的 ASCII 翻译形式  -E, --encoding=编码      use selected output encoding      --no-hyphenation, --nh turn off hyphenation      --no-justification,                              --nj   turn off justification  -p, --preprocessor=字符串   字符串表示要运行哪些预处理器:                             e - [n]eqn, p - pic, t - tbl,g - grap, r - refer, v - vgrind  -t, --troff                使用 groff 对手册页排版  -T, --troff-device[=设备]   使用 groff 的指定设备  -H, --html[=浏览器]     使用 www-browser 或指定浏览器显示 HTML                             输出  -X, --gxditview[=分辨率]   使用 groff 并通过 gxditview (X11)                             来显示:                             -X = -TX75, -X100 = -TX100, -X100-12 = -TX100-12  -Z, --ditroff              使用 groff 并强制它生成 ditroff  -?, --help                 give this help list      --usage                give a short usage message  -V, --version              print program version
例如:
 man ifconfig #查看ifconfig手册
0 0
原创粉丝点击