man命令使用指南

man命令是linux下查找shell命令、函数等使用方法的利器。最简单的使用方式是man <the thing you want>。掌握上面那条命令应该也可以满足80%的使用场景了。这里记录一些更加深入的man命令使用的方法,如果还不能满足查询需求,就只能man man再深挖了。

man <section> <pagename>
这条命令可以在指定的section中去查询想要搜索的指南,因为一个pagename可能对应多个分属不同section的page,例如直接man signalman 7 signal出来的内容是完全不一样的。man具有的常用section如下

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, 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)
9 Kernel routines [Non standard]

man -a <pagename>
这条命令可以显示关于要查找的这个page的所有内容,不过是一页一页显示,并不是很方便,使用man -aw <pagename>可以看到全部的信息路径。

~$ man -aw signal
/usr/share/man/man2/signal.2.gz
/usr/share/man/man7/signal.7.gz

man -k <regex>
这条命令可以按正则表达式在所有section的所有page中去搜索,返回匹配的page和其简单的介绍

~$ man -k .*open.*
openocd (1)          - A free and open on-chip debugging, in-system programming and boundary-scan testing tool for ARM and MIPS systems
RAND (7ssl)          - the OpenSSL random generator
Ast_helper.Opn (3o)  - Opens
Ast_iterator (3o)    - Ast_iterator.iterator enables AST inspection using open recursion.
authorized_keys (5)  - OpenSSH daemon
CA.pl (1ssl)         - friendlier interface for OpenSSL certificate programs
catclose (3)         - open/close a message catalog
catopen (3)          - open/close a message catalog
config (5ssl)        - OpenSSL CONF library configuration files
creat (2)            - open and possibly create a file
crypto (7ssl)        - OpenSSL cryptographic library
dbopen (3)           - database access methods
des_modes (7ssl)     - the variants of DES and other crypto algorithms of OpenSSL

man -f <keyword>
这个用法等价于whatis <keyword>,可以从系统中搜索出和keyword相关的指南。

~$ man -f Git
Git (3pm)            - Perl interface to the Git version control system
git (1)              - the stupid content tracker

~$ whatis git
Git (3pm)            - Perl interface to the Git version control system
git (1)              - the stupid content tracker

man -Kw <regex>
全局搜索正则表述的关键字,把结果路径显示出来,这个搜索有点慢。

~$ man -Kw SIGILL
/usr/share/man/man1/python3.8.1.gz
/usr/share/man/man1/python3.8.1.gz
/usr/share/man/man3/Stdlib.Sys.3o.gz
/usr/share/man/man3/Sys.3o.gz
/usr/share/man/man2/sigaction.2.gz
/usr/share/man/man2/sigaction.2.gz
/usr/share/man/man2/signal.2.gz
/usr/share/man/man2/sigprocmask.2.gz
/usr/share/man/man2/sigprocmask.2.gz
/usr/share/man/man7/signal.7.gz

以上这些命令应该可以cover住90%以上的man使用场景。

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值