Linux - 命令

查看命令的帮助信息

只需在相关命令后面使用 -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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值