Linux手册页项目记录了用户空间程序使用的Linux内核和C库接口。
用man手册查看系统命令,系统调用,glibc函数时,会发现其后面会有个括号,括号里面是一个数字,比如:
access(2), awk(1), crash(1), fattach(3C), ff(1), fstat(8), fuser(1), gethostname(2), isprint(3), kill(1), localtime(3), lstat(2), modload(8), mount(8), netstat(1), ofiles(8L), perl(1),
ps(1), readlink(2), setlocale(3), stat(2), strftime(3), time(2), uname(1).
Linux手册页记录了用户空间程序使用的Linux内核和C库接口(主要是GNU C库(glibc)):
1: User commands; man-pages includes a small number of Section 1 pages that document programs supplied by the GNU C library.
2: System calls documents the system calls provided by the Linux kernel.
3: Library functions documents the functions provided by the standard C library.
4: Devices documents details of various devices, most of which reside in /dev.
5: Files describes various file formats and filesystems, and includes proc(5), which documents the /proc file system.
7: Overviews, conventions, and miscellaneous.
8: Superuser and system administration commands; man-pages includes a small number of Section 8 pages that document programs supplied by the GNU C library.
下图表示进程的地址空间。图的左侧是说进程可以通过什么方式来更改进程虚拟地址空间,而中间就是进程虚拟地址空间是如何划分的,右侧则是进程的虚拟地址空间所对应的物理内存或者说物理地址空间。
其中函数括号中的数字2代表该函数是系统调用,3代表该函数是库函数。
图片来自于 极客时间:Linux内核技术实战
很多系统调用都有两个手册页:用户命令和系统调用。
比如 readlink :
[root@localhost ~]# man 1 readlink
READLINK(1) User Commands READLINK(1)
NAME
readlink - print resolved symbolic links or canonical file names
SYNOPSIS
readlink [OPTION]... FILE...
[root@localhost ~]# man 2 readlink
READLINK(2) Linux Programmer's Manual READLINK(2)
NAME
readlink - read value of a symbolic link
SYNOPSIS
#include
ssize_t readlink(const char *path, char *buf, size_t bufsiz);
还有些库函数也有多个手册页,比如 netlink :
netlink(3) //用 man 3 netlink 查看
netlink(7) //用 man 7 netlink 查看
极客时间:Linux内核技术实战
https://www.kernel.org/doc/man-pages/