Linux MAN命令的使用技巧

在Linux的shell下我经常要使用Linux man命令来查看一些不熟悉的命令的使用方法。最经在shell下编程的时候,发现一些c和c++中的库函数。不清楚,我都跑去网上搜索了。一不小心,我发现,原来Linux man还可以用来查询系统库文件中的一些函数定义和使用方法。

Linux man中的man就是manual的缩写,用来查看系统中自带的各种参考手册,但是手册页分为好几个部分,如下所示:

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]

在shell中输入 man+数字+命令/函数 即可以查到相关的命令和函数。若不加数字,那Linux man命令默认从数字较小的手册中寻找相关命令和函数。

例如,本来是想寻找c标准库中的rand()函数,直接使用man rand得到的是一个rand命令的手册,直接用来产生一个随机数,这个内容在手册section 1中。如果使用man 3 rand就可以得到自己想要的库函数中rand()的用法了。


====

http://os.51cto.com/art/201003/188192.htm

--------------------------------------------------------------------------------------------------------------------------------------------

我们经常会看到 在说一个对象的man page 的时候,会有这样的格式:

mmap(2) 

shm_open(3)

这个后面的数字是什么意思呢,通过 man man 命令就可以知道,这个是数字是,section

大多数类unix 操作系统,都采用相同的section 的约定:

Section 1

user commands ( introduction)
Section 2
system calls ( introduction)
Section 3
library functions ( introduction)
Section 4
special files ( introduction)
Section 5
file formats ( introduction)
Section 6
games ( introduction)
Section 7
conventions and miscellany ( introduction)
Section 8
administration and privileged commands ( introduction)
Section L
math library functions
Section N
tcl functions

通过后面的数字,你就能明白一个函数是系统调用,还是只是一个类库中的一个函数。这个数字还是相当有意义的。

====

http://www.cnblogs.com/niniwzw/archive/2011/01/20/1939953.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值