查看帮助的通用方法

man

系统自带的一些命令,或者使用包管理器(yum,apt-get之类)安装的命令,基本都有man帮助

man pwd
man  --help
man man
type man

/search-string 
n 向后查找
N 向前查找 
&search-string 只显示包含查找内容的行
h 帮助
q 退出

info

这个相对来说比man命令显示的更详细,比如大家可以自行对比下man sedinfo sed,后者就像一本书一样,内容翔实,不过同man命令类似,基本是系统自带命令或者包管理器安装的命令才能用它

info info
info man
info pwd
info --help

s search-string  查找
{ 向后查找
} 向前查找
h 帮助
q 退出

–help -help -h -?

mkdir --help

有时候直接输入命令即可以查看帮助 docker

根据提示还可以查看第2层命令的帮助 docker container --help

但是有些命令直接输入不是查看帮助,比如直接输入nginx命令是启动nginx,这可不是我们想要的,这个时候我们可以

nginx --help
nginx -help
nginx help
nginx -h
nginx -?

一般总有一个是对的,当然这样随便测试,前提是在测试环境下,如果都看不到帮助则大概率是这厮根本没有内置帮助,可寻求百度搜索下

help (bash内嵌的命令)

有种情况比较特殊,大家可能都遇到过,比如执行man cd,看到的是下面这样一堆堆,似乎乱糟糟的

最上面那一堆命令表明,这些命令属于内嵌在bash里的命令,从这里找到帮助信息比较麻烦,此时可以用

help cd
help help

[root@node1 ~]# type cd
cd is a shell builtin
[root@node1 ~]# type type
type is a shell builtin
[root@node1 ~]# type cp
cp is aliased to `cp -i'
[root@node1 ~]# type which 
which is aliased to `alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'

type CMD可以用来判断某个命令是不是内嵌命令,还可以用来判断某个命令是否有别名

whatis

这个命令可以用来简要解释命令,查看一个命令的多种帮助类型

[root@node1 ~]# whatis ls
ls (1)               - list directory contents
[root@node1 ~]# whatis cd
cd (1)               - bash built-in commands, see bash(1)

[root@node1 ~]# whatis nginx
nginx (8)            - "HTTP and reverse proxy server, mail proxy server"
nginx (3pm)          - Perl interface to the nginx HTTP server API
[root@node1 ~]# man 3 nginx

whatis whatis
whatis man
whatis help
whatis bash

which

# whatis which 
which (1)            - shows the full path of (shell) commands.

[root@node1 tmp]# which cp
alias cp='cp -i'
	/usr/bin/cp
[root@node1 tmp]# which grep
alias grep='grep --color=auto'
	/usr/bin/grep
[root@node1 tmp]# which cd
/usr/bin/cd

whereis

# whatis whereis
whereis (1)          - locate the binary, source, and manual page files for a command

这个命令也可以用来搜索命令的所在位置

[root@node1 tmp]# whereis grep
grep: /usr/bin/grep /usr/share/man/man1/grep.1.gz

一些在线帮助