man
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了man相关的知识,希望对你有一定的参考价值。
man
【功能说明】:
man - formatand display the on-line manual pages #格式化显示在线手册页
man命令是Linux获取帮助文档的重要工具,它是manual的缩写,通过man可以查询Linux中的命令、配置文件、编程等帮助信息;man适用于查询外部命令的帮助信息
【语法格式】:
man [-acdDfFhkKtwW] [--path] [-msystem] [-p string] [-C config_file] [-M pathlist] [-P pager] [-B browser] [-Hhtmlpager] [-S section_list] [section] name ...
man [选项] [参数] [命令/配置文件]
【手册部分】:
1 UserCommands #用户命令
2 System Calls #系统调用
3 C Library Functions #C语言库函数
4 Devices and Special Files #设备和特殊文件
5 FileFormats and Conventions #配置文件
6 Games et. Al. #游戏 其它
7 Miscellanea #宏 包其它杂项
8 SystemAdministration tools and Deamons #系统管理员相关的命令
--------------------------------------------------------
n 新文档,可能要移到更适合的领域。
o 老文档,可能会在一段期限内保留。
l 本地文档,与本特定系统有关的。
--------------------------------------------------------
其中1,5,8要记住,1为用户命令,5为配置文件,8为系统命令需要root权限。
注释实例:
知道上述数字的含义,我们就可以使用man 2 write来查看关于write系统调用的帮助信息了。
[[email protected] ~]# man write WRITE(1) Linux Programmer’s Manual WRITE(1) NAME write - send a message to another user
[[email protected] ~]# man 2 write WRITE(2) Linux Programmer’s Manual WRITE(2) NAME write - write to a file descriptor
【选项参数】:
选项 | 说明 |
-a <command/config file> | 显示所有匹配项,按q键切换到下一帮助手册,如后面没有手册,则退出 |
-f <command/config file> | 等同于whatis命令,将在whatis数据库查找以关键字开头的帮助索引信息 |
-h <command/config file> | 显示man命令的帮助信息 |
-k <command/config file> | 等同于apropos命令,搜索whatis数据库,模糊查找关键字 |
-w <command/config file> | 输出找到帮助手册的文件路径,默认搜索一个文件后停止 |
-S <list> <command/config file> | 指定搜索的帮助手册领域 |
section <number> <command/config file> | 指定搜索帮助手册的领域,【限定查找帮助手册类型】 |
【实践操作】:
1、man -a <command> 参数实例
[[email protected] tools]# man -a write WRITE(1) Linux Programmer’sManual WRITE(1) NAME write- send a message to another user SYNOPSIS writeuser [ttyname] …… <此处忽略若干字符> 按q切换到下一手册页 WRITE(1P) POSIX Programmer’sManual WRITE(1P) PROLOG This manual page is part of the POSIX Programmer’s Manual. The Linux implementation of this interfacemay differ (consult the corresponding Linuxmanual page for details of Linux behavior), or the interface may not beimplemented on Linux. NAME write- write to another user SYNOPSIS writeuser_name [terminal] …… <此处忽略若干字符> 按q切换到下一手册页 WRITE(2) Linux Programmer’sManual WRITE(2) NAME write- write to a file descriptor SYNOPSIS #include <unistd.h> ssize_t write(int fd, const void *buf, size_t count);
2、man -a <config file> 参数实例
[[email protected] tools]# man -a fstab FSTAB(5) Linux Programmer’sManual FSTAB(5) NAME fstab- static information about the filesystems SYNOPSIS #include <fstab.h> DESCRIPTION The file fstab contains descriptive informationabout the various file systems. fstab isonly read by programs, and not written; it is the dutyof the system administrator to properly create and maintain this file. Each filesystem is described on a separateline; fields on each line are separated by tabs orspaces. Lines starting with ’#’ arecomments. blank lines are ignored. Theorder of records in fstab is impor- tantbecause fsck(8), mount(8), and umount(8) sequentially iterate through fstabdoing their thing.
3、man -f <command> 参数实例
[[email protected] tools]# man -f write write (1p) - write to another user write (1) - send a message to another user write (2) - write to a file descriptor write (3p) - write on a file [[email protected] tools]# whatis write write (1p) - write to another user write (1) - send a message to another user write (2) - write to a file descriptor write (3p) - write on a file
4、man -f <config file> 参数实例
[[email protected] tools]# man -f fstab fstab (5) - static information about the filesystems fstab-decode (8) - run a command with fstab-encoded arguments [[email protected] tools]# whatis fstab fstab (5) - static information about the filesystems fstab-decode (8) - run a command with fstab-encoded arguments
5、man -h <command/config file> 参数实例
[[email protected] tools]# man -h write man, version 1.6f usage: man [-adfhktwW] [section] [-M path] [-Ppager] [-S list] [-msystem] [-p string] name ... a : findall matching entries c : do notuse cat file d : printgobs of debugging information D : as for-d, but also display the pages f : sameas whatis(1) h : printthis help message k : sameas apropos(1) K : searchfor a string in all pages t : usetroff to format pages for printing w : printlocation of man page(s) that would be displayed (if noname given: print directories that would be searched) W : as for-w, but display filenames only C file : use `file‘ as configuration file M path : set search path for manual pagesto `path‘ P pager : use program `pager‘ to displaypages S list : colon separated section list m system :search for alternate system‘s man pages p string :string tells which preprocessors to run e - [n]eqn(1) p - pic(1) t - tbl(1) g - grap(1) r - refer(1) v - vgrind(1)
6、man -k <command/config file> 参数实例
[[email protected] tools]# man -k write aio_write (3) - asynchronous write aio_write (3p) - asynchronous write to a file (REALTIME) amidi (1) - read from and write to ALSA RawMIDI ports bzero (3) - write zero-valued bytes chan (n) - Read, write and manipulate channels cksum (1p) - write file checksums and sizes creat (3p) - create a new file or rewrite an existingone …… write (1p) - write to another user write (1) - send a message to another user write (2) - write to a file descriptor write (3p) - write on a file writemain [ExtUtils::Miniperl] (3pm) - write the C code for perlmain.c writev (3p) - write a vector writev [readv] (2) - read or write data into multiple buffers zipnote (1) - write the comments in zipfile to stdout,edit comments and rename files in zipfile [[email protected] tools]# man -k fstab endfsent [getfsent] (3) -handle fstab entries fstab (5) - static information about the filesystems fstab-decode (8) - run a command with fstab-encoded arguments getfsent (3) - handle fstab entries getfsfile [getfsent] (3) - handle fstab entries getfsspec [getfsent] (3) - handle fstab entries setfsent [getfsent] (3) -handle fstab entries
7、man -w <command/config file> 参数实例
[[email protected] tools]# man -w write /usr/share/man/man1/write.1.gz [[email protected] tools]# man -w fstab /usr/share/man/man5/fstab.5.gz
8、man -S <list> < command/config file >参数实例
[[email protected] tools]# man -S 2 write WRITE(2) Linux Programmer’sManual WRITE(2) NAME write- write to a file descriptor SYNOPSIS #include <unistd.h> ssize_t write(int fd, const void *buf, size_t count); DESCRIPTION write()writes up to count bytes from the buffer pointed buf to the file referred to bythe file descriptor fd.
9、man section <number> < command/config file > 参数实例
[[email protected] tools]# man section 3p write No manual entry for section WRITE(3P) POSIX Programmer’sManual WRITE(3P) PROLOG This manual page is part of the POSIX Programmer’s Manual. The Linux implementation of this interfacemay differ (consult the corresponding Linuxmanual page for details of Linux behavior), or the interface may not beimplemented on Linux. NAME pwrite, write - write on a file SYNOPSIS #include <unistd.h> ssize_t pwrite(int fildes, const void *buf,size_t nbyte, off_t offset); ssize_t write(int fildes, const void *buf, size_t nbyte); [[email protected] tools]# man section 5 fstab No manual entry for section FSTAB(5) Linux Programmer’s Manual FSTAB(5) NAME fstab- static information about the filesystems SYNOPSIS #include <fstab.h>
【技巧拓展】:
1、man命令的配置文件
/etc/man.config
2、man命令默认搜索帮助手册的顺序
MANSECT 1:1p:8:2:3:3p:4:5:6:7:9:0p:n:l:p:o:1x:2x:3x:4x:5x:6x:7x:8x
3、man命令快捷键整理
e、 j、回车<Enter> #前进一行
y、 k #后退一行
f、空格键 #前进一屏
b或 w #后退一屏
d #前进半屏
u #后退半屏
/<string> #由上向下搜寻string字符串
?<string> #由后向前搜寻string字符串
n #查看下一个找到的字符串
N #查看上一个找到的字符串
g #跳转到第一行
G #跳转到最后一行
p #跳转到文件开头
q #退出帮助手册
本文出自 “Marin” 博客,请务必保留此出处http://marin.blog.51cto.com/11904838/1905861
以上是关于man的主要内容,如果未能解决你的问题,请参考以下文章