查看命令的帮助信息
只需在相关命令后面使用 -h
或 --help
选项即可。例如,查看 whereis
命令的帮助信息:
# whereis --help
Usage:
whereis [options] [-BMS <dir>... -f] <name>
Locate the binary, source, and manual-page files for a command.
Options:
-b search only for binaries
-B <dirs> define binaries lookup path
-m search only for manuals and infos
-M <dirs> define man and info lookup path
-s search only for sources
-S <dirs> define sources lookup path
-f terminate <dirs> argument list
-u search for unusual entries
-l output effective lookup paths
-h, --help display this help
-V, --version display version
For more details see whereis(1).
但是,有一些命令没有 -h
或 --help
选项,例如:
# which --help
Illegal option --
Usage: /usr/bin/which [-a] args
这时,可以使用 man
命令,例如:
# man which
WHICH(1) General Commands Manual WHICH(1)
NAME
which - locate a command
SYNOPSIS
which [-a] filename ...
DESCRIPTION
which returns the pathnames of the files (or links) which would be executed in the
current environment, had its arguments been given as commands in a strictly POSIX-
conformant shell. It does this by searching the PATH for executable files matching
the names of the arguments. It does not canonicalize path names.
OPTIONS
-a print all matching pathnames of each argument
EXIT STATUS
0 if all specified commands are found and executable
1 if one or more specified commands is nonexistent or not executable
2 if an invalid option is specified
Debian 29 Jun 2016 WHICH(1)
...skipping...
WHICH(1) General Commands Manual WHICH(1)
NAME
which - locate a command
SYNOPSIS
which [-a] filename ...
DESCRIPTION
which returns the pathnames of the files (or links) which would be executed in the
current environment, had its arguments been given as commands in a strictly POSIX-
conformant shell. It does this by searching the PATH for executable files matching
the names of the arguments. It does not canonicalize path names.
OPTIONS
-a print all matching pathnames of each argument
EXIT STATUS
0 if all specified commands are found and executable
1 if one or more specified commands is nonexistent or not executable
2 if an invalid option is specified
Debian 29 Jun 2016 WHICH(1)
查看命令的相关信息
返回将在当前环境中执行的文件(或链接)的路径名:
# which tar
/bin/tar
为指定的命令名查找二进制文件、源文件和手册:
# whereis tar
tar: /usr/lib/tar /bin/tar /usr/include/tar.h /usr/share/man/man1/tar.1.gz