一、前言
正所謂了解一個命令就得了解他的用法,正好是要了解一個人就得了解他的興趣愛好,處事態度以及為人是怎么樣的。
二、man是什么
man – an interface to the on-line reference manuals
Man是manual(手冊)的縮寫,使用權限是所有用戶,man命令提供為linux系統在線提供了很好的幫助手冊,幾乎可以說不懂就問問這個“男人”吧。
三、man都有哪些呢
man 既然是手冊,那COMMAND一定也會有會有手冊,這時候就可以看man的手冊如圖3-1
圖3-1man的描述
DESCRIPTION(描述)
man 是一個系統幫助手冊,每頁都是不同的參數
man is the system's manual pager. Each page argument given to man is normally
the name of a program, utility or function. The manual page associated with
each of these arguments is then found and displayed. A section, if provided,
will direct man to look only in that section of the manual. The default
action is to search in all of the available sections, following a pre-defined
order and to show only the first page found, even if page exists in several
sections.
man是一個系統幫助手冊,man有著不同章節,每個頁面章節是man 的項目的名稱,
實用程序或功能,這些參數相關的手冊頁發現并顯示,如果提供手冊頁的章節會把那 章節的內容輸出,默認的查找是在所有可用的搜索結果,按照預定義的順序只顯示第 一個手冊頁,即使還有其他手冊頁。
相關的手冊頁有;
1 Executable programs or shell commands
用戶命令
2 System calls (functions provided by the kernel)
系統調用
3 Library calls (functions within program libraries)
C庫調用
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]
內核常規(非標準)
注意:有些關鍵字在不止一個章節中存在幫助:
要查看指定章節中的手冊:man#COMMAND (#代表數字)
四、man的查看方式
Man的有哪些頁已經知道,當然還得知道怎么樣查看和翻閱。
man命令的操作方法既less:
Space,ctrl+v,ctrl+f,ctrl+F,:向文件尾部翻屏:
b,ctrl+B:向文件首部翻屏:
d,ctrl+D:向文件尾部翻半屏:
u,ctrl+U:向文件首部翻半屏:
RETURN or ctrl+N, e ,ctrl+E, j, ctrl+J:向文件尾部翻一行:
y,ctrl+Y,ctrl+P,k,ctrl+K: 向文件首部翻一行
q:退出
#:跳轉至第#行:
1G:回到文件首部
G:翻至文件尾部
文本搜索:
/KEYWORD:
以KEYWORD指定的字符串為關鍵字,從當前位置向文件首部搜索:不區分字符大小寫:
n:跟搜索命令同方向,下一個
N:跟搜索命令反方向,上一個
五、man的路徑
Man的查看和翻閱知道了 那就的知道man 的命令是在那里, man命令的路徑在那
[root@localhost etc]# whereis man
man: /usr/bin/man /usr/share/man /usr/share/man/man1/man.1.gz
六、man 的用法
了解了什么是man,當然得了解man都有哪些用法。
圖5-1 man的用法
Man有很多選項:
Non argument options that are duplicated either on the command line, in$MANOPT, or both, are not harmful. For options that require an argument, each
duplication will override the previous argument value.
非參數選項在命令行中復制$MANOPT,或者兩者都有,并不是所有的選項需要參數,每個重復參數將覆蓋前面的參數值。
以下是man運用的例子
圖5-2 man的例子
EXAMPLES
man ls
Display the manual page for the item (program) ls.
顯示項目手冊頁或程序 ls
man -a intro
Display, in succession, all of the available intro manual pages contained within the manual. It is possible to quit between successive displays or skip any of them.
顯示,連續,所有可用的介紹手冊頁中包含的手冊。可以退出之間連續顯示或跳過其中任何一個。
man -t alias | lpr -Pps
Format the manual page referenced by `alias', usually a shell manual page, into the default troff or groff format and pipe it to the printer named ps. The default output for
groff is usually PostScript. man –help should advise as to which processor is bound to the -t option.
格式手冊頁面引用的“別名”,通常是一個shell手冊頁面,默認troff或groff格式和管輸出叫ps。groff的默認輸出通常是PostScript。man——幫助應該建議哪些處理器綁定到– t選項。
man -l -Tdvi ./foo.1x.gz > ./foo.1x.dvi
This command will decompress and format the nroff source manual page ./foo.1x.gz into a device independent (dvi) file. The redirection is necessary as the -T flag causes out?
put to be directed to stdout with no pager. The output could be viewed with a program such as xdvi or further processed into PostScript using a program such as dvips.
這個命令是解壓和使用 groff 的指定設備, ./foo.1x.gz 是一個設備獨立文件,重定向是必要的
輸出可以與xdvi等程序或進一步加工成PostScript使用dvips等程序。
man -k printf
Search the short descriptions and manual page names for the keyword printf as regular expression. Print out any matches. Equivalent to apropos -r printf.
. 使用帶有-k選項的man命令可以根據關鍵字搜索聯機幫助。如查找printf
man -f string
Lookup the manual pages referenced by smail and print out the short descriptions of any found. Equivalent to whatis -r smail.
查找命令頁中被引用的信息string 輸出,短的說明,man -f 等同于 whatis -r smile
七、命令總結
想要使用或不知道某個命令,man可以幫助你,man有多個手冊頁,你想知道這個命令有哪些手冊頁可使用man -k COMMAND。
然后你就可以在有的手冊頁上查看,想到那個手冊頁可使用 man # COMMAND #代表數字。還有…
原創文章,作者:N19_king,如若轉載,請注明出處:http://www.www58058.com/15831