Shell命令-线上查询及帮助之man、help

线上查询及帮助 - man、help

1、man:获取命令的帮助信息

man命令的简单介绍

man命令是Linux系统中最核心的命令之一 ,因为通过它可以查看其它Linux命令的使用信息。当然了 ,man命令不仅可以查看命令的使用帮助 ,还可以查看软件 服务配置文件、系统调用、库函数等的帮助信息。

man命令的功能说明

man命令用于查看命令的帮助信息。

man命令的语法格式

man [参数选项] 命令/文件

man命令的选项说明

man 选项不常用,此处省略。

man命令的实践操作

范例1:使用man查看cp命令的帮助

[root@oldboyedu  ~]# 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命令

[root@oldboyedu  ~]# 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.
[root@oldboyedu  ~]# 

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

[root@oldboyedu  ~]# 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.
...

今天就写到这里,有什么疑问或出现什么错误,随时欢迎大神们发表评论指点迷津

猜你喜欢

转载自blog.51cto.com/14068656/2375082