N天学习一个Linux命令之帮助命令:man

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了N天学习一个Linux命令之帮助命令:man相关的知识,希望对你有一定的参考价值。

前言

工作中每天都在使用常用的命令和非常用的命令,忘记了用法或者参数,都会bing一下,然后如此循环。一直没有真正的系统的深入的去了解命令的用法,我决定打破它。以前看到有人,每天学习一个linux命令,我现在没有这么充足时间,我恐怕一周学习一个linux命令我都做不到,想想我还是N天学习一个linux命令吧,从现在开始算起。

 

用途

显示命令帮助文档以及用法

 

用法

man [options] [section] cmd

 

命令文档部分说明

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.

 

常用参数用法

显示命令版本

[[email protected] ~]# man -V
man 2.6.3

查看命令帮助信息

[[email protected] ~]# man -h
Usage: man [OPTION...] [SECTION] PAGE...

显示指定命令的配置文件

默认配置所使用的配置文件/etc/man_db.conf
[[email protected] ~]# man -C /etc/man.conf man

显示调试信息

[[email protected] ~]# man -d man
From the config file /etc/man_db.conf:
Mandatory mandir `/usr/man‘.
Mandatory mandir `/usr/share/man‘.
Mandatory mandir `/usr/local/share/man‘.
Path `/bin‘ mapped to mandir `/usr/share/man‘.
Path `/usr/bin‘ mapped to mandir `/usr/share/man‘.
Path `/sbin‘ mapped to mandir `/usr/share/man‘.
Path `/usr/sbin‘ mapped to mandir `/usr/share/man‘.
Path `/usr/local/bin‘ mapped to mandir `/usr/local/man‘.
Path `/usr/local/bin‘ mapped to mandir `/usr/local/share/man‘.
Path `/usr/local/sbin‘ mapped to mandir `/usr/local/man‘.

输出命令原始文档所在路径

[[email protected] ~]# man -w man
/usr/share/man/man1/man.1.gz

输出命令转义文档所在路径

[[email protected] ~]# man -W man

显示指定输出文档内容使用的命令

默认使用的命令是less
[[email protected] ~]# man -P cat man
MAN(1) Manual pager utils MAN(1)
NAME
man - an interface to the on-line reference manuals

输出格式化文档之后的文本格式内容

[[email protected] ~]# man man | col -b > man.log

 

后记

1 大部分命令都会有帮助文档,man命令可以跟这些帮助文档交互。
2 后端开发多多少少都需要维护类unix服务器,平时多深入了解命令的用法会对平时的工作很有帮助。

 

参考资料

【1】man -h 以及 man man

以上是关于N天学习一个Linux命令之帮助命令:man的主要内容,如果未能解决你的问题,请参考以下文章

N天学习一个Linux命令之帮助命令:grep

linux基础之帮助文档---常用的命令

Linux基础之man帮助命令实战

学会用Linux的帮助命令

每天需学点linux之-man命令

Linux命令之获得帮助信息man