Linux whereis命令查找二进制文件
source link: https://www.myfreax.com/whereis-command-in-linux/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Linux whereis命令查找二进制文件
whereis是一个命令行程序,可让您查找给定命令的二进制文件
Linux whereis命令查找二进制文件
whereis是一个命令行程序,可让您查找给定命令的二进制文件,源文件和手册页文件的位置。
在本教程中,我们将向您展示如何在Linux使用whereis命令。包括whereis语法与选项,一次搜索多个二进制文件,指定目录查找文件等。
whereis
命令的语法形式是whereis [OPTIONS] FILE_NAME...
。
不带任何选项运行whereis
命令时,它将会在环境变量PATH包含的目录,源文件和手册文件目录中搜索指定的命令。
你可以使用-l
选项运行命令whereis -l
列出whereis
命令要搜索的目录。例如,要获取bash
命令的信息,请运行命令whereis bash
。
whereis -l
whereis bash
bash: /bin/bash /etc/bash.bashrc /usr/share/man/man1/bash.1.gz
在输出中,bash是要获取信息的命令,/bin/bash
是bash二进制文件的路径,/etc/bash.bashrc
是源文件,/usr/share/man/man1/bash.1.gz
是手册页。
如果您要搜索的命令不存在,whereis
将打印命令名称。您还可以使用whereis
一次搜索多个命令。
例如命令whereis netcat uptime
的输出将包含netcat
和uptime
命令的信息。
whereis netcat uptime
netcat: /bin/netcat /usr/share/man/man1/netcat.1.gz
uptime: /usr/bin/uptime /usr/share/man/man1/uptime.1.gz
要仅搜索命令二进制文件的位置,请使用-p
选项运行whereis。例如要查找ping
命令的二进制文件位置,可以运行命令whereis -p ping
。
当仅搜索命令二进制文件的位置时,请优先使用which
或type
命令。要仅搜索源文件,请使用-s
选项。
如果源文件存在,则whereis
将打印其位置。-m
选项仅允许您搜索手册文件的位置。
whereis -p ping
whereis -s command
whereis -m command
ping: /bin/ping
要限制whereis
搜索二进制文件的位置,请使用-B
选项,对于手册文件的位置,请选择-M
选项,对于源请使用-S
。每个选项均以空格分隔。
例如,要在/bin
目录中搜索cp
命令的二进制文件,请运行命令whereis -b -B /bin -f cp
。
whereis -b -B /bin -f cp
cp: /bin/cp
whereis
命令用于查找给定命令的二进制文件,源文件和手册文件。如果您有任何疑问或反馈,请在下面发表评论。
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK