用過linux的朋友估計沒有誰不熟悉man命令,大家都知道利用它可以查看到linux絕大部分命令的使用方法(但不是全部),除了這個你還了解它什麼呢?其實了解man可以查看其它命令的使用方法就掌握了它的核心,但是最近看書的時候又找到了它的一點其他信息。哈哈,你就將這篇文章當做扯談吧!~
1. man其實是manual的縮寫(不會很多人認為它是"男人"吧),表示手冊、指南的意思。
2. 其實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.我們平常主要用到的是man1和man5,當我們敲出man命令時,www.linuxidc.com默認的就是man1,例如man ls實際上等價的就是man 1 ls。這是最常用的,此時man會告訴我們這個命令(程序)的用法。而平常也偶爾會用到man5,比如你要查看/etc/fstab這個文件裡面每一行每一列的的解釋那麼你就可以使用 man 5 fstab。那麼你就可以得到相關解釋信息。至於其他的man,估計很少會用到。
這些man的所對應的信息都是在/usr/share/man/這個目錄下:
xxx@db-2:~$ ls /usr/share/man
cs de es fi fr gl hu id it ja ko man1 man2 man3 man4 man5 man6 man7 man8 nl pl pt pt_BR ru sv tr zh_CN zh_TW
其實每個manx的目錄下的每個文件都是程序名或者稱為命令名+x+.gz組成的,你解壓之後可以看到裡面是文本信息。另外,我們在man查看命令使用方法時,經常會看到第一行有command(數字),還有最後的SEE ALSO部分也是command(數字)這種信息,其實括號裡面的信息就是表面你可以通過man 數字 command可以查看到相關信息,比如 man mkfs。
好了。