Linux的whereis命令

whereis 可以查找指定命令的二进制文件、源文件和帮助文件。 被找到的文件在显示时,会去掉主路径名,然后再去掉文件的(单个)尾部扩展名 (如: .cc),来源于源代码控制的 s. 前缀也会被去掉。接下来,whereis 会尝试在标准的 Linux 位置里寻找具体程序,也会在由 $PATH$MANPATH 指定的路径中寻找。

1
whereis [options] [-BMS directory... -f] name...

命令寻找二进制文件所在位置

1
2
3
4
5
[root@study ~]# whereis whereis
whereis: /usr/bin/whereis /usr/share/man/man1/whereis.1.gz
[root@study ~]# whereis ls
ls: /usr/bin/ls /usr/share/man/man1/ls.1.gz
[root@study ~]#

使用 -b 选项在搜索时规定只搜索二进制文件

1
2
3
4
5
6
7
8
[root@study ~]# whereis -b ls
ls: /usr/bin/ls
[root@study ~]# whereis -b whereis
whereis: /usr/bin/whereis
[root@study ~]# whereis -b ls whereis
ls: /usr/bin/ls
whereis: /usr/bin/whereis
[root@study ~]#

使用 -m 选项在搜索时规定只搜索帮助页面文件

1
2
3
4
5
6
7
8
[root@study ~]# whereis -m ls
ls: /usr/share/man/man1/ls.1.gz
[root@study ~]# whereis -m whereis
whereis: /usr/share/man/man1/whereis.1.gz
[root@study ~]# whereis -m ls whereis
ls: /usr/share/man/man1/ls.1.gz
whereis: /usr/share/man/man1/whereis.1.gz
[root@study ~]#

使用 -s 选项在搜索时规定只搜索源代码文件

1
2
3
4
[root@study ~]# whereis -s ls
ls:[root@study ~]#
[root@study ~]# whereis -s whereis
whereis:[root@study ~]#

使用 -u 选项找到一个有异常条目的命令。对于 whereis 命令来说,如果一个命令对每个显式的请求类型都不止一项,则该命令被视为异常。例如,没有可用文档的命令,或者对应文档分散在各处的命令都可以算作异常命令。 当使用 -u 这一选项,whereis 就会显示那些有异常条目的命令。

在当前目录中,寻找没有对应文档或有多个文档的命令

1
whereis -m -u *

使用 -l 选项查看 whereis 的搜索路径

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
[root@study ~]# whereis -l
bin: /usr/bin
bin: /usr/sbin
bin: /usr/lib
bin: /usr/lib64
bin: /etc
bin: /usr/etc
bin: /usr/games
bin: /usr/local/bin
bin: /usr/local/sbin
bin: /usr/local/etc
bin: /usr/local/lib
bin: /usr/local/games
bin: /usr/include
bin: /usr/local
bin: /usr/libexec
bin: /usr/share
man: /usr/share/man/man1
man: /usr/share/man/man5
man: /usr/share/man/man7
man: /usr/share/man/man8
man: /usr/share/man/man0p
man: /usr/share/man/man1p
man: /usr/share/man/man1x
man: /usr/share/man/man2
man: /usr/share/man/man2x
man: /usr/share/man/man3
man: /usr/share/man/man3p
man: /usr/share/man/man3x
man: /usr/share/man/man4
man: /usr/share/man/man4x
man: /usr/share/man/man5x
man: /usr/share/man/man6
man: /usr/share/man/man6x
man: /usr/share/man/man7x
man: /usr/share/man/man8x
man: /usr/share/man/man9
man: /usr/share/man/man9x
man: /usr/share/man/mann
man: /usr/share/man/fr
man: /usr/share/man/ja
man: /usr/share/man/ko
man: /usr/share/man/pl
man: /usr/share/man/ru
man: /usr/share/man/sk
man: /usr/share/man/cs
man: /usr/share/man/da
man: /usr/share/man/de
man: /usr/share/man/hu
man: /usr/share/man/id
man: /usr/share/man/it
man: /usr/share/man/pt_BR
man: /usr/share/man/sv
man: /usr/share/man/tr
man: /usr/share/man/zh_CN
man: /usr/share/man/zh_TW
man: /usr/share/man/pt
man: /usr/share/man/es
man: /usr/share/man/hr
man: /usr/share/man/pt_PT
man: /usr/share/man/ro
man: /usr/share/man/zh
man: /usr/share/man/nl
src: /usr/src/debug
src: /usr/src/kernels
[root@study ~]#
有钱任性,请我吃包辣条
0%