[Linux命令] man命令

man命令查看系统帮助手册(manual)

基本的用法:

$ man ls

LS(1)                                               User Commands                                               LS(1)

NAME
       ls - list directory contents

SYNOPSIS
       ls [OPTION]... [FILE]...

DESCRIPTION
       List  information  about the FILEs (the current directory by default).  

操作说明:
执行man命令后,进入man操作界面,显示查询命令的帮助内容。
在这个界面下操作方式:
1)q键,退出man命令。
2)方向键、page-up、page-down上下翻页。
3)'/'进入搜索模式,输入关键字或者正则表达式。

用关键字查询

列出包含关键字“printf”相关的帮助。
每项括号中的数字是man章节(section)号。

$ man -k printf
asprintf (3)         - print to allocated string
caca_conio_cprintf (3caca) - The libcaca public header.
caca_conio_printf (3caca) - The libcaca public header.
caca_printf (3caca)  - (unknown subject)
caca_vprintf (3caca) - (unknown subject)
dprintf (3)          - formatted output conversion
fprintf (3)          - formatted output conversion
fwprintf (3)         - formatted wide-character output conversion
printf (1)           - format and print data
printf (3)           - formatted output conversion
snprintf (3)         - formatted output conversion
sprintf (3)          - formatted output conversion
swprintf (3)         - formatted wide-character output conversion
vasprintf (3)        - print to allocated string
vdprintf (3)         - formatted output conversion
vfprintf (3)         - formatted output conversion
vfwprintf (3)        - formatted wide-character output conversion
vprintf (3)          - formatted output conversion
vsnprintf (3)        - formatted output conversion
vsprintf (3)         - formatted output conversion
vswprintf (3)        - formatted wide-character output conversion
vwprintf (3)         - formatted wide-character output conversion
wprintf (3)          - formatted wide-character output conversion

man section

分类说明

帮助内容分了几个大类,即section。分类如下:

shell 命令                      1   Executable programs or shell commands
Linux系统接口函数        2   System calls (functions provided by the kernel)
C语言库函数                 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]

大部分情况下,不需要指定section,前提是没有重复。例如上面的例子中,看ls帮助直接查阅就可以。
当不同类别中有重复的内容时,就需要指定section。例如上面查询关键字‘printf’,结果中可以看到2个完全一样的同名帮助项。第一个是shell命令中的printf,第二个是系统接口(C函数库)的printf。

printf (1)           - format and print data
printf (3)           - formatted output conversion

不指定section

不指定section就默认显示最小section编号中对应的命令。
如果只输入’man printf’,会显示shell中的printf命令(section号更小):

$ man printf

PRINTF(1)                                           User Commands                                           PRINTF(1)

NAME
       printf - format and print data

SYNOPSIS
       printf FORMAT [ARGUMENT]...
       printf OPTION

指定section

通过指定section,可以查看特定的手册页:
以下2中方式效果相同,都是指定在section 3中,查询printf。

$ man printf.3
$ man 3 printf
PRINTF(3)                                     Linux Programmer's Manual                                     PRINTF(3)

NAME
       printf, fprintf, dprintf, sprintf, snprintf, vprintf, vfprintf, vdprintf, vsprintf, vsnprintf - formatted out‐
       put conversion

这是比较常用的一些功能,更细节的功能请查阅:

$ man man

猜你喜欢

转载自blog.csdn.net/yinminsumeng/article/details/129547172