作用:查看Linux中指令的帮助、配置文件帮助、编程函数的帮助等信息。
语法:man [OPTION...] [SECTION] PAGE
man命令的所有参数如下:
[root@lena file]# man --help
Usage: man [OPTION...] [SECTION] PAGE...
-C, --config-file=FILE use this user configuration file
-d, --debug emit debugging messages
-D, --default reset all options to their default values
--warnings[=WARNINGS] enable warnings from groff
Main modes of operation:
-f, --whatis equivalent to whatis #等价于whatis命令 显示指定关键词的简单描述
-k, --apropos equivalent to apropos
-K, --global-apropos search for text in all pages
-l, --local-file interpret PAGE argument(s) as local filename(s)
-w, --where, --path, --location
print physical location of man page(s)
-W, --where-cat, --location-cat
print physical location of cat file(s)
-c, --catman used by catman to reformat out of date cat pages
-R, --recode=ENCODING output source page encoded in ENCODING
Finding manual pages:
-L, --locale=LOCALE define the locale for this particular man search
-m, --systems=SYSTEM use manual pages from other systems
-M, --manpath=PATH set search path for manual pages to PATH #指定man手册搜索的路径
-S, -s, --sections=LIST use colon separated section list
-e, --extension=EXTENSION limit search to extension type EXTENSION
-i, --ignore-case look for pages case-insensitively (default)
-I, --match-case look for pages case-sensitively
--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 find all matching manual pages #在所有的man帮助手册中搜索
-u, --update force a cache consistency check
--no-subpages don't try subpages, e.g. 'man foo bar' => 'man
foo-bar'
Controlling formatted output:
-P, --pager=PAGER use program PAGER to display output #分页显示
-r, --prompt=STRING provide the `less' pager with a prompt
-7, --ascii display ASCII translation of certain latin1 chars
-E, --encoding=ENCODING use selected output encoding
--no-hyphenation, --nh turn off hyphenation
--no-justification, --nj turn off justification
-p, --preprocessor=STRING STRING indicates which preprocessors to run:
e - [n]eqn, p - pic, t - tbl,
g - grap, r - refer, v - vgrind
-t, --troff use groff to format pages
-T, --troff-device[=DEVICE] use groff with selected device
-H, --html[=BROWSER] use elinks or BROWSER to display HTML output
-X, --gxditview[=RESOLUTION] use groff and display through gxditview
(X11):
-X = -TX75, -X100 = -TX100, -X100-12 = -TX100-12
-Z, --ditroff use groff and force it to produce ditroff
-?, --help give this help list
--usage give a short usage message
-V, --version print program version #查看版本
选项:
数字:指明从哪个man手册中搜索得到帮助
关键字:指名需要搜索帮助的关键词
如果使用指令man 2 关键词
的时候出现以下提示:
[root@lena file]# man 2 open
No manual entry for open in section 2
这时候需要使用命令yum install -y man-pages
安装,这时候重新查询即可看到以下信息:可以查看到该函数需要指定的库,该函数需要携带的参数等信息。
OPEN(2) Linux Programmer's Manual OPEN(2)
NAME
open, creat - open and possibly create a file or device
SYNOPSIS
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
int open(const char *pathname, int flags);
int open(const char *pathname, int flags, mode_t mode);
int creat(const char *pathname, mode_t mode);
DESCRIPTION
Given a pathname for a file, open() returns a file descriptor, a small, nonnegative
integer for use in subsequent system calls (read(2), write(2), lseek(2), fcntl(2),
etc.). The file descriptor returned by a successful call will be the lowest-numbered
file descriptor not currently open for the process.
By default, the new file descriptor is set to remain open across an execve(2) (i.e.,
the FD_CLOEXEC file descriptor flag described in fcntl(2) is initially disabled; the
O_CLOEXEC flag, described below, can be used to change this default). The file off‐
set is set to the beginning of the file (see lseek(2)).
A call to open() creates a new open file description, an entry in the system-wide ta‐
ble of open files. This entry records the file offset and the file status flags
(modifiable via the fcntl(2) F_SETFL operation). A file descriptor is a reference to
Manual page open(2) line 1 (press h for help or q to quit)