linux命令協助

來源:互聯網
上載者:User

標籤:des   c   class   blog   code   tar   

Linux命令格式:
command [options] [arguments]
command:命令
options: 參數

[] 表示是可選的;
<> 表示是可變化的;
x|y|z 表示只能選擇一個;
-abc 表示三個參數(或任何二個)的混合使用

1.whereis 

?
1 2 [[email protected]]# whereis nc nc: /usr/bin/nc /usr/share/man/man1/nc.1.gz

2.whatis

?
1 2 3 [[email protected]]# whatis nc nc                   (1)  - arbitrary TCP and UDP connections and listens nc                  (rpm) - Reads and writes data across network connections using TCP or UDP.

3.  --help 

?
1 2 3 4 5 [[email protected]]# nc --hellp nc: invalid option -- - usage: nc [-46DdhklnrStUuvzC] [-i interval] [-p source_port]           [-s source_ip_address] [-T ToS] [-w timeout] [-X proxy_version]           [-x proxy_address[:port]] [hostname] [port[s]]

4.man:man就是manual的縮寫,用來查看系統中內建的各種參考手冊,但是手冊頁分為好幾個部分,如下所示:  

?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 1 Executable programs or shell commands(使用者命令協助)   2 System calls (系統調用協助)   3 Library calls (庫函數調用協助)   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]
?
1 2 3 4 5 6 7 8 解釋一下, 1是普通的命令 2是系統調用,如open,write之類的(通過這個,至少可以很方便的查到調用這個函數,需要加什麼標頭檔) 3是庫函數,如printf,fread4是特殊檔案,也就是/dev下的各種裝置檔案 5是指檔案的格式,比如passwd, 就會說明這個檔案中各個欄位的含義 6是給遊戲留的,由各個遊戲自己定義 7是附件還有一些變數,比如向environ這種全域變數在這裡就有說明 8是系統管理用的命令,這些命令只能由root使用,如ifconfig

在shell中輸入 man+數字+命令/函數 即可以查到相關的命令和函數。若不加數字,那Linux man命令預設從數字較小的手冊中尋找相關命令和函數。

例如,嘗試看看不同結果:

man 1 open

man 2 open

man 3 open

b. 所有命令的線上說明都有相同的基本格式,從第1行可以知道這是關於哪個命令的協助,還可以知道這個協助是位於哪一節的。

        名字(NAME)部分包含命令的名字以及對這個命令的簡短說明。

        概要(SYNOPSYS)部分給出了命令的用法說明,包括命令格式、參數和選項列表。在線上說明中方括弧表示該選項不是一個必須的部分。

        描述(DESCRIPTION)部分是關於命令功能的詳細闡述,是這個命令的權威性解釋。

        選項(OPTIONS)部分給出了命令列中每一個選項說明。

        參閱(SEE ALSO)部分包含了與這個命令相關的其它主題。有些協助還有BUG部分。  

?
1 2 3 4 5 6 [[email protected]]# man -k ifconfig   <span>使用帶有-k選項的man命令可以根據關鍵字搜尋線上說明</span> ifconfig             (8)  - configure a network interface [[email protected]]# man -k netstat gnome-netstatus     (rpm) - Network status applet netstat              (8)  - Print network connections, routing tables, interface statistics, masquerade connections, and multicast memberships snmpnetstat          (1)  - display networking status and configuration information from a network entity via SNMP
?
1 2 3 4 [[email protected]]# man -f ifconfig  <span>使用帶有-f選項的man命令可以根據關鍵字在線上說明中搜尋完全符合的條目</span> ifconfig             (8)  - configure a network interface [[email protected]]# man -f netstat netstat              (8)  - Print network connections, routing tables, interface statistics, masquerade connections, and multicast memberships
?
1 2 3 4 5 6 7 8 9 10 11 g. man中常用的按鍵: 按鍵  進行工作 空白鍵 向下翻一頁 [Page Down] 向下翻一頁,↓為向下一行 [Page Up]   向上翻一頁,↑為向上一行 [Home]  去到第一頁 [End]   去到最後一頁 /string 向『下』搜尋 string 這個字串,如果要搜尋vbird 的話,就輸入 /vbird ?string 向『上』搜尋 string 這個字串 n, N    利用 / 或 ? 來搜尋字串時,可以用 n 來繼續下一個搜尋 (不論是 / 或 ?) ,可以利用 N 來進行『反向』搜尋。舉例來說,我以 /vbird 搜尋 vbird 字串, 那麼可以 n 繼續往下查詢,用 N 往上查詢。若以 ?vbird 向上查詢 vbird 字串, 那我可以用 n 繼續『向上』查詢,用 N 反向查詢。 q   結束這次的 man page

d. 和命令info、--help配合使用;

e. 到書籤:在man中,若當前做書籤,按m鍵,再按字母a,便產生了一個標記為a的書籤,瀏覽到任何頁面,想回到標記為a的書籤頁面,按‘鍵(引號和單引號鍵)便回到a的標記;

f. man中運行命令,使用!,再敲入命令,如!date,按斷行符號鍵返回;

<FROM:http://blog.csdn.net/dijkstar/article/details/6882325> 

  

  

  

  

  

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.