linux中的帮助命令

2020-02-19 16:02:42来源:博客园 阅读 ()

新老客户大回馈,云服务器低至5折

linux中的帮助命令

目录

  • man
  • whatis
  • apropos
  • --help
  • info
  • help

    man

    解释

命令名称:man
命令英文原意:manual
命令所在路径:/usr/bin/man
执行权限:所有用户
功能描述:获得帮助信息

语法

man [命令或配置文件]

示例

# 查看ls命令的帮助信息
man ls
    空格    下翻页
    pageup  上翻页
    上箭头  向上
    下箭头  向下
    /关键字 搜索(回车搜索,n往下找)
    
    
# 查看/etc/services配置文件帮助文档
man services
    提示No manual entry for services
    运行命令yum -y install man-pages,然后就可以运行了
    
    
# 查看/etc/passwd配置文件的帮助文档(不正确)
man passwd
    查询出来的命令的帮助文档,此时是不对的
    
whereis passwd    
[root@izm5e2q95pbpe1hh0kkwoiz ~]# whereis passwd
passwd: /usr/bin/passwd /etc/passwd /usr/share/man/man1/passwd.1.gz /usr/share/man/man5/passwd.5.gz
    passwd既有命令又有配置文件,优先显示命令的帮助文档
    1 命令的帮助文档
    5 配置文件的帮助文档

# 查看passwd配置文件的帮助文档
man 5 passwd

whatis

查看命令的简单的描述信息

示例

# 查看ls的简单的描述信息
whatis ls

[root@izm5e2q95pbpe1hh0kkwoiz ~]# whatis ls
ls (1)               - list directory contents

apropos

查看配置文件的简单的描述信息

示例

# 查看services的简单描述信息
apropos services

--help

查看某个具体命令的选项信息

示例

# 查看touch命令的具体选项信息
touch --help

[root@izm5e2q95pbpe1hh0kkwoiz ~]# touch --help
Usage: touch [OPTION]... FILE...
Update the access and modification times of each FILE to the current time.

A FILE argument that does not exist is created empty, unless -c or -h
is supplied.

A FILE argument string of - is handled specially and causes touch to
change the times of the file associated with standard output.

Mandatory arguments to long options are mandatory for short options too.
  -a                     change only the access time
  -c, --no-create        do not create any files
  -d, --date=STRING      parse STRING and use it instead of current time
  -f                     (ignored)
  -h, --no-dereference   affect each symbolic link instead of any referenced
                         file (useful only on systems that can change the
                         timestamps of a symlink)
  -m                     change only the modification time
  -r, --reference=FILE   use this file's times instead of current time
  -t STAMP               use [[CC]YY]MMDDhhmm[.ss] instead of current time
      --time=WORD        change the specified time:
                           WORD is access, atime, or use: equivalent to -a
                           WORD is modify or mtime: equivalent to -m
      --help     display this help and exit
      --version  output version information and exit

Note that the -d and -t options accept different time-date formats.

GNU coreutils online help: <http://www.gnu.org/software/coreutils/>
For complete documentation, run: info coreutils 'touch invocation'

info

使用方法跟man 几乎一致, 显示的信息也大同小异

help

解释

命令名称:help
命令所在路径:shell内置命令(无法通过which查找路径,无法通过man查看帮助文档)
执行权限:所有用户
功能描述:获得shell内置命令的帮助信息

语法

help [命令]

示例

# 使用man查看shell内置命令(无法查看正确的帮助信息)
man cd

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)
......

# man 查询cd查不出来正确的帮助文档信息,相反查出来的是shell的内置命令



# 正确查看shell内置命令的帮助文档信息,查看umask
help umask

[root@izm5e2q95pbpe1hh0kkwoiz ~]# help umask
umask: umask [-p] [-S] [mode]
    Display or set file mode mask.
    
    Sets the user file-creation mask to MODE.  If MODE is omitted, prints
    the current value of the mask.
    
    If MODE begins with a digit, it is interpreted as an octal number;
    otherwise it is a symbolic mode string like that accepted by chmod(1).
    
    Options:
      -p        if MODE is omitted, output in a form that may be reused as input
      -S        makes the output symbolic; otherwise an octal number is output
    
    Exit Status:
    Returns success unless MODE is invalid or an invalid option is given.

原文链接:https://www.cnblogs.com/eternityz/p/12329992.html
如有疑问请与原作者联系

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:linux中shell内置命令和外置命令

下一篇:忘记root密码