Linux which/whereis/locate命令详解

which 查看可执行文件的位置,从全局环境变量PATH里面查找对应的路径,默认是找 bash内所规范的目录

whereis 查看文件的位置,配合参数-b,用于程序名的搜索,从linux数据库查找。

locate 配合数据库查看文件位置。

find 实际搜寻硬盘查询文件名称,效率低。

which常用命令参数

--version, -[vV] Print version and exit successfully.
--help,          Print this help and exit successfully.
--skip-dot       Skip directories in PATH that start with a dot.
--skip-tilde     Skip directories in PATH that start with a tilde.
--show-dot       Don't expand a dot to current directory in output.
--show-tilde     Output a tilde for HOME directory for non-root.
--tty-only       Stop processing options on the right if not on tty.
--all, -a        Print all matches in PATH, not just the first
--read-alias, -i Read list of aliases from stdin.
--skip-alias     Ignore option --read-alias; don't read stdin.
--read-functions Read shell functions from stdin.
--skip-functions Ignore option --read-functions; don't read stdin.

which常用的命令展示

which cp  ==> /bin/cp

image

 

whereis常用命令参数

# Usage:  whereis [ -sbmu ] [ -SBM dir ... -f ] name...

whereis  -b  cp    ==>which cp  ==> /bin/cp

image

locate常用命令参数

Usage: locate [OPTION]... [PATTERN]...
Search for entries in a mlocate database.

  -b, --basename         match only the base name of path names
  -c, --count            only print number of found entries
  -d, --database DBPATH  use DBPATH instead of default database (which is
                         /var/lib/mlocate/mlocate.db)
  -e, --existing         only print entries for currently existing files
  -L, --follow           follow trailing symbolic links when checking file
                         existence (default)
  -h, --help             print this help
  -i, --ignore-case      ignore case distinctions when matching patterns
  -l, --limit, -n LIMIT  limit output (or counting) to LIMIT entries
  -m, --mmap             ignored, for backward compatibility
  -P, --nofollow, -H     don't follow trailing symbolic links when checking file
                         existence
  -0, --null             separate entries with NUL on output
  -S, --statistics       don't search for entries, print statistics about each
                         used database
  -q, --quiet            report no error messages about reading databases
  -r, --regexp REGEXP    search for basic regexp REGEXP instead of patterns
      --regex            patterns are extended regexps
  -s, --stdio            ignored, for backward compatibility
  -V, --version          print version information
  -w, --wholename        match whole path name (default)

locate常用的命令展示

locate cp   ==> which cp  ==> /bin/cp

image

转载于:https://www.cnblogs.com/ftl1012/p/which.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值