1. 程式人生 > >Shell命令-線上查詢及幫助之man、help

Shell命令-線上查詢及幫助之man、help

== gin 選項說明 字符 physical etop ado types eterm

線上查詢及幫助 - man、help

1、man:獲取命令的幫助信息

man命令的簡單介紹

man命令是Linux系統中最核心的命令之一 ,因為通過它可以查看其它Linux命令的使用信息。當然了 ,man命令不僅可以查看命令的使用幫助 ,還可以查看軟件 服務配置文件、系統調用、庫函數等的幫助信息。

man命令的功能說明

man命令用於查看命令的幫助信息。

man命令的語法格式

man [參數選項] 命令/文件

man命令的選項說明

man 選項不常用,此處省略。

man命令的實踐操作

範例1:使用man查看cp命令的幫助

[[email protected]  ~]# man cp      <-->一般不加參數,直接跟命令

man命令其實用法很簡單,關鍵就是幫助文檔是英文版的,對於一些英文不是很好的學習者來說,簡直跟天書似的,在此,我也無能為力,不過可以借助一些翻譯工具等。也可以使用搜索引擎進行翻譯。

表1:執行man命令後幫助內容中的標題介紹(大部分命令)

man幫助信息中的標題 功能說明(帶*為重點)
NAME 命令說明及介紹(常見)*
SYNOPSIS 命令的基本使用語法(常見)*
DESCRIPTION 命令使用詳細描述,以及相關參數說明(常用)*
OPTIONS 命令相關參數選項說明
COMMANDS 在執行這個程序(軟件)的時候,在此可執行
FILES 程序涉及(或使用或關聯)的相關文件
EXAMPLES 命令的一些例子*
SEE ALSO 和命令相關的信息說明
BUGS (REPORTING BUGS) 命令對應缺陷問題的描述
COPYRIGHT 版權信息相關聲明
AUTHOR 作者介紹

表2man幫助頁面中的快捷鍵

操作鍵 功能說明
[Page Down] 向下翻一頁(可用空格鍵替代)
[Page Up] 向上翻一頁
[Home] 跳轉到第一頁
[End] 跳轉到最後一頁
/word 向下依次查找word字符串(通常跟N或n鍵使用)
?word 向上依次查找word字符串(通常跟N或n鍵使用)
q 結束本次man幫助

2、help:獲取bash內置命令的幫助信息

help命令的簡單介紹

Linux系統裏有一些特殊的命令 ,它們就是bash程序的內置命令 ,例如cdhistoryread等 ,這些命令在系統目錄裏不存在真實的程序文件(存在於bash程序裏 ),對於這部分命令,查看幫助的方法就是使用help命令

help命令的實踐操作

範例1:使用help查看cd命令

[[email protected]  ~]# help cd
cd: cd [-L|[-P [-e]]] [dir]
    Change the shell working directory.

    Change the current directory to DIR.  The default DIR is the value of the
    HOME shell variable.

    The variable CDPATH defines the search path for the directory containing
    DIR.  Alternative directory names in CDPATH are separated by a colon (:).
    A null directory name is the same as the current directory.  If DIR begins
    with a slash (/), then CDPATH is not used.

    If the directory is not found, and the shell option `cdable_vars‘ is set,
    the word is assumed to be  a variable name.  If that variable has a value,
    its value is used for DIR.

    Options:
        -L  force symbolic links to be followed
        -P  use the physical directory structure without following symbolic
        links
        -e  if the -P option is supplied, and the current working directory
        cannot be determined successfully, exit with a non-zero status

    The default is to follow symbolic links, as if `-L‘ were specified.

    Exit Status:
    Returns 0 if the directory is changed, and if $PWD is set successfully when
    -P is used; non-zero otherwise.
[[email protected]  ~]# 

範例2:使用man查看cd命令

[[email protected]  ~]# man cd
BASH_BUILTINS(1)                                      General Commands Manual                                      BASH_BUILTINS(1)
==========================================================
**提示以下命令在bash裏(CentOS7有的bash內置命令也可以使用man查詢)**
==========================================================
NAME
       bash,  :,  .,  [, alias, bg, bind, break, builtin, caller, cd, command, compgen, complete, compopt, continue, declare, dirs,
       disown, echo, enable, eval, exec, exit, export, false, fc, fg, getopts, hash, help, history, jobs, kill, let, local, logout,
       mapfile,  popd,  printf,  pushd,  pwd,  read, readonly, return, set, shift, shopt, source, suspend, test, times, trap, true,
       type, typeset, ulimit, umask, unalias, unset, wait - bash built-in commands, see bash(1)

BASH BUILTIN COMMANDS
       Unless otherwise noted, each builtin command documented in this section as accepting options preceded by  -  accepts  --  to
       signify  the end of the options.  The :, true, false, and test builtins do not accept options and do not treat -- specially.
       The exit, logout, break, continue, let, and shift builtins accept and process arguments beginning with -  without  requiring
       --.  Other builtins that accept arguments but are not specified as accepting options interpret arguments beginning with - as
       invalid options and require -- to prevent this interpretation.
...

今天就寫到這裏,有什麽疑問或出現什麽錯誤,隨時歡迎大神們發表評論指點迷津

Shell命令-線上查詢及幫助之man、help