man 命令是 Linux 中最经常使用的命令,碰到任何让你疑惑的命令,均可以 man 一下来查看详情。不仅是 shell 命令,C 语言库函数和系统调用等内容也能够经过 man 命令查看。linux
man 命令默认查看的是 shell 命令的文档,能够指定参数 2 查看系统调用,3 查看 C 库函数(须要提早安装)。能够在 Linux 中直接输入 man man
查看 man 命令的帮助文档,最经常使用的就是查看 shell 命令、系统调用和库函数,例如:web
man printf man 2 open man 3 printf
man 文档:shell
NAME man - an interface to the on-line reference manuals SYNOPSIS man [-C file] [-d] [-D] [--warnings[=warnings]] [-R encoding] [-L locale] [-m system[,...]] [-M path] [-S list] [-e extension] [-i|-I] [--regex|--wildcard] [--names-only] [-a] [-u] [--no-subpages] [-P pager] [-r prompt] [-7] [-E encoding] [--no-hyphenation] [--no-justification] [-p string] [-t] [-T[device]] [-H[browser]] [-X[dpi]] [-Z] [[section] page[.section] ...] ... man -k [apropos options] regexp ... man -K [-w|-W] [-S list] [-i|-I] [--regex] [section] term ... man -f [whatis options] page ... man -l [-C file] [-d] [-D] [--warnings[=warnings]] [-R encoding] [-L locale] [-P pager] [-r prompt] [-7] [-E encoding] [-p string] [-t] [-T[device]] [-H[browser]] [-X[dpi]] [-Z] file ... man -w|-W [-C file] [-d] [-D] page ... man -c [-C file] [-d] [-D] page ... man [-?V] DESCRIPTION man is the system's manual pager. Each page argument given to man is normally the name of a program, utility or function. The manual page associated with each of these arguments is then found and displayed. A section, if provided, will direct man to look only in that section of the manual. The default action is to search in all of the available sections following a pre-defined order ("1 n l 8 3 2 3posix 3pm 3perl 3am 5 4 9 6 7" by default, unless overrid‐ den by the SECTION directive in /etc/manpath.config), and to show only the first page found, even if page exists in several sections. The table below shows the section numbers of the manual followed by the types of pages they contain. 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] A manual page consists of several sections.
各大 Linux 发行版默认带了 shell 命令的 man 文档,其余文档须要本身下载。bash
官方下载连接:https://mirrors.edge.kernel.org/pub/linux/docs/man-pages/ 。在 man-pages-posix 文件夹下,有 POSIX 的 man 手册。less
wget https://www.kernel.org/pub/linux/docs/man-pages/man-pages-4.16.tar.gz tar -xvzf man-pages-4.16.tar.gz cd man-pages-4.16 make install
固然也能够用 Linux 发行版自带的仓库安装,例如 Ubuntu:ide
apt-get install manpages
首先执行下面的命令,若是报错找不到文档,则说明没有安装:svg
man 3 printf
Ubuntu 下须要一个个单独安装,或用通配符一次安装:函数
apt-get install manpages-dev apt-get install manpages*
CentOS 则能够一次安装:spa
yum install man-pages