Linux man手册的基本组成和使用方法
Linux man手册的基本组成和使用方法
根本方法:在命令行中输入man man
可以查看man手册的详细使用方法,这里记录一些目前用到的内容。
1. man手册的基本结构
man手册主要分为9个部分,分别是(序号后标*为常用手册)
手册序号 | 英文介绍 | 中文介绍 |
---|---|---|
1* | Executable programs or shell commands | 可执行程序和shell命令 |
2* | System calls (functions provided by the kernel) | 系统调用 |
3* | Library calls (functions within program libraries) | (C语言)库函数 |
4 | Special files (usually found in /dev) | 特殊文件 |
5 | File formats and conventions, e.g. /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) | 系统管理员命令(通常只用于roor用户) |
9 | Kernel routines [Non standard] | 内核例程(非标准) |
2. man手册查询查用命令和功能
-
man <keyword>
:查询任意关键词(不包括结构体,类型定义),但由于存在同名关键词,如read(1)
(shell命令)与read(2)
(linux系统调用),这样查询只会显示位于前面的手册,如man read
显示read(1)
结果,这时就需要指定手册序号。 -
man 1 <program or shell command>
:查询可执行程序或shell命令的用法,如:man 1 cd
,man 1 ls
等; -
man 2 <system-call>
:查询系统调用相关信息,如man 2 read
,man 2 write
等。 -
man 3 <lib-call>
:查询C语言库函数相关信息,如man 3 printf
,man 3 exit
等。 -
man 7 <option>
:查询杂项,如man 7 socket
,man 7 ip
等。 -
man -K <struct name>
:可以用来查询不知道具体在哪个手册页的(函数、结构体、类型)定义,如man -K sockaddr_in
。
3. 安装额外man手册
pthread库调用的man手册安装
当我们想查看pthread_create()
函数的使用方法时,输入man pthread
显示无条目,需要自己安装。
在ubuntu下,可以通过:sudo apt-get install manpages-posix manpages-posix-dev
安装POSIX man手册,
再输入man pthread_create
即可显示结果。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 2025年我用 Compose 写了一个 Todo App
· 张高兴的大模型开发实战:(一)使用 Selenium 进行网页爬虫