Skip to content Skip to main navigation Skip to footer

CentOS /Linux: 深入理解Man 命令

Linux 命令 man可能是我们在学习linux的时候最早使用的命令之一。大家都知道man命令可以帮助我们了解其它命令的使用方法。 除了这些,你对 Linux man 命令还有其它的了解吗?本文将会给大家讲述下的 Linux Man 命令的背后的事情。
linux操作系统
man命令主要用来格式化显示命令的在线帮助页面,这些帮助信息主要会有每个命令的开发者编写。
man 命令的帮助信息主要包含8个部分:
man1: User programs
Manual pages that describe publicly accessible commands are contained
in this chapter. Most program documentation that a user will need to
use is located here.
man2: System calls
This section describes all of the system calls (requests for the kernel
to perform operations).
man3: Library functions and subroutines
Section 3 describes program library routines that are not direct calls
to kernel services. This and chapter 2 are only really of interest to
programmers.
man4: Special files
Section 4 describes the special files, related driver functions, and
networking support available in the system. Typically, this includes
the device files found in /dev and the kernel interface to networking
protocol support.

man5: File formats

The formats for many data files are documented in the section 5. This
includes various include files, program output files, and system files.
man6: Games
This chapter documents games, demos, and generally trivial programs.
Different people have various notions about how essential this is.
man7: Miscellaneous Manual pages that are difficult to classify are
designated as being section 7. The troff and other text processing
macro packages are found here.
man8: System administration Programs used by system administrators
for system operation and maintenance are documented here. Some of
these programs are also occasionally useful for normal users.
当我们使用man命令去查看某个命令的帮助信息时候,主要显示的是第一部分的内容和第五部分的内容,也就是man 1和man 5. 比如用man ls命令,其实是 man 1 ls. 在帮助信息里的最上面你可以看到 LS(1)的信心,这个1就代表调用的是man 1.
man命令的所有信息都保存在/usr/share/man目录下:
[cc lang=”php”] [root@itsprite ~]# ls -l /usr/share/man
total 352
drwxr-xr-x. 5 root root 4096 Dec 17 2012 bg
drwxr-xr-x. 5 root root 4096 Apr 3 2012 cs
drwxr-xr-x. 5 root root 4096 Dec 17 2012 da
drwxr-xr-x. 5 root root 4096 Apr 3 2012 de
drwxr-xr-x. 5 root root 4096 Dec 17 2012 el
drwxr-xr-x. 5 root root 4096 Dec 17 2012 en
drwxr-xr-x. 5 root root 4096 Dec 17 2012 es
drwxr-xr-x. 5 root root 4096 Dec 17 2012 fi
drwxr-xr-x. 6 root root 4096 Apr 3 2012 fr
drwxr-xr-x. 5 root root 4096 Dec 17 2012 hr
drwxr-xr-x. 4 root root 4096 Dec 17 2012 hu
drwxr-xr-x. 3 root root 4096 Dec 17 2012 id
drwxr-xr-x. 6 root root 4096 Apr 3 2012 it
drwxr-xr-x. 5 root root 4096 Apr 3 2012 ja
drwxr-xr-x. 5 root root 4096 Dec 17 2012 ko
drwxr-xr-x. 2 root root 4096 Sep 23 2011 man0p
drwxr-xr-x. 2 root root 36864 May 12 2014 man1
drwxr-xr-x. 2 root root 4096 Sep 23 2011 man1p
drwxr-xr-x. 2 root root 4096 Sep 23 2011 man1x
drwxr-xr-x. 2 root root 4096 Sep 23 2011 man2
drwxr-xr-x. 2 root root 4096 Sep 23 2011 man2x
drwxr-xr-x. 2 root root 110592 Apr 22 2014 man3
drwxr-xr-x. 2 root root 4096 Sep 23 2011 man3p
drwxr-xr-x. 2 root root 4096 Sep 23 2011 man3x
drwxr-xr-x. 2 root root 4096 Dec 17 2012 man4
drwxr-xr-x. 2 root root 4096 Sep 23 2011 man4x
drwxr-xr-x. 2 root root 4096 Apr 22 2014 man5
drwxr-xr-x. 2 root root 4096 Sep 23 2011 man5x
drwxr-xr-x. 2 root root 4096 Sep 23 2011 man6
drwxr-xr-x. 2 root root 4096 Sep 23 2011 man6x
drwxr-xr-x. 2 root root 4096 Apr 22 2014 man7
drwxr-xr-x. 2 root root 4096 Sep 23 2011 man7x
drwxr-xr-x. 2 root root 20480 May 12 2014 man8
drwxr-xr-x. 2 root root 4096 Sep 23 2011 man8x
drwxr-xr-x. 2 root root 4096 Sep 23 2011 man9
drwxr-xr-x. 2 root root 4096 Sep 23 2011 man9x
drwxr-xr-x. 2 root root 4096 Sep 23 2011 mann
drwxr-xr-x. 5 root root 4096 Dec 17 2012 nl
drwxr-xr-x. 5 root root 4096 Apr 3 2012 pl
drwxr-xr-x. 5 root root 4096 Dec 17 2012 pt
drwxr-xr-x. 5 root root 4096 Dec 17 2012 pt_BR
drwxr-xr-x. 5 root root 4096 Dec 17 2012 ro
drwxr-xr-x. 6 root root 4096 Dec 17 2012 ru
drwxr-xr-x. 3 root root 4096 Dec 17 2012 sk
drwxr-xr-x. 5 root root 4096 Dec 17 2012 sl
drwxr-xr-x. 6 root root 4096 Dec 17 2012 sv
drwxr-xr-x. 5 root root 4096 Dec 17 2012 tr
drwxr-xr-x. 4 root root 4096 Dec 17 2012 zh_CN
drwxr-xr-x. 4 root root 4096 Dec 17 2012 zh_TW
[/code] 如果你先查看某个命令在当前系统都包含哪几部分的帮助信息,可以使用”man -f” 命令来查看:
[cc lang=”php”] [root@osetc man5]# man -f init
init (5) – Upstart init daemon job configuration
init (8) – Upstart process management daemon
[/code] [cc lang=”php”] 查看某个命令的所有的man帮助信息,使用命令“man -a“
[root@itsprite man5]# man -a init
[/code] 该命令会先显示man 8的 帮助信息,当退出之前的页面,会自动显示man 5 的帮助信息。

0 Comments

There are no comments yet

Leave a comment

Your email address will not be published.